Results 1 to 11 of 11

Thread: suggestions needed

  1. #1

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    suggestions needed

    I am creating a virtual cabinet in which I have many files say thousands. Each file can belong to one or more categories that is why In data base there should be a Bit mask through which the file can be retrieved. That mask should be a 32 bit binary number.
    There are levels of the categories. All major categories have sub categories and those sub categories can also have sub sub categories. A file can belong to a sub category and it can also then belong to a major category. like if there is a major category A which have sub category B and Category B have a sub sub category C and there is another major category X which have a sub category Y and there is a file Z which belongs to the category Y and can belongs to category B.
    Each category and sub category has also a bit mask ( 32 bit number) .As it is a 32 bit binary number there are 4 chunks of 8 bits . first chunk is for the major category second chunk of 8 bit is for sub category and 3rd chunk is for sub sub category and 4th one is for sub sub sub category . for the above example the bit mask would be

    Category A = 00000000 00000000 00000000 00000001
    Category B = 00000000 00000000 00000001 00000001
    Category C = 00000000 00000001 00000001 00000001

    Category X = 00000000 00000000 00000000 00000010
    Category Y = 00000000 00000000 00000001 00000010

    So from the mask C we can easily see that it belongs to a sub catogry B and it has a major category A

    Now I would like to know that what would be a the bit mask of the file Z. which belongs to both the Y and B catgory.so that I can depict from where it belongs .

    any suggestions would be appriciated

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    00000000 00000000 00000001 00000011
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    ?

    how did you make that. i mean which logic you used to come up with this number

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    To add bitmasks together you Or the numbers.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Lively Member
    Join Date
    Nov 2002
    Posts
    78
    Category A = 00000000 00000000 00000000 00000001
    Category B = 00000000 00000000 00000001 00000001
    Category C = 00000000 00000001 00000001 00000001

    is this right ?

    i would have thought that the mask C would have looked like

    00000000 00000000 00000001 00000001 ????

  6. #6

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333
    Yes, but if i OR them then it would become much confusing. like in this case

    00000000 00000000 00000001 00000011

    this bit mask can also depict that this is a sub catogorey of third major category... got it or not .. so then how would i diffrentiate that ?

  7. #7
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Ok. What you would want to do is something like this :

    CatA : 00000001
    CatB : 00000010
    CatC : 00000100
    CatD : 00001000
    CatE : 00010000
    CatF : 00100000
    CatG : 01000000
    CatH : 10000000

    So by Or'ing the numbers together you can specify that an object is a member of any category A - H, and combinations too.

    Eg: An item is a member of CatA and CatB and CatG :
    01000011
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    ok then ?

    then how would i decrypt this OR thingy

  9. #9
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You AND a field against it, and if you get the same value back, then that value has been set.

    Eg :

    Item is in CatA and CatF :
    Bitfield : 00100001


    To check if it is a member of CatB :
    00000010 = 00100001 And 00000010

    The above expression would return False.
    But if you wanted to check if it was a member of CatA :

    00000001 = 00100001 And 00000010

    The above expression would be True.
    (00100001 And 00000010 would return 00000001)
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  10. #10

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    Lightbulb but

    this things would only applicable if we have a file belongs to only two major categories .. but what here a file can alos belong to a sub sub category . so how would this method apply in that case.

    please refer to my first post for the sub sub categories

  11. #11
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Then you would maintain a second bitfield, and use the same technique again.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width