Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Unique Selection

dve83dve83 Member Posts: 30
[b][red]This message was edited by dve83 at 2007-3-18 7:15:21[/red][/b][hr]
Hi, my head's not on straight it seems. I need to determine the unique selection of checkboxes. When the form displays, each Checkbox's tag get populated with 1,2,4,8,16,32 etc etc. If I'm right, when adding up these values (based on the selection) you'll get a unique integer fro every possible combination. So ok, lets say I selected 1,2 and 8 then I get 11. So now I return this value to the calling form -> but how do I get abck to 1,2 and 8 from 11. I'm stumped. thanks in advance.


Comments

  • zibadianzibadian Member Posts: 6,349
    : [b][red]This message was edited by dve83 at 2007-3-18 7:15:21[/red][/b][hr]
    : Hi, my head's not on straight it seems. I need to determine the unique selection of checkboxes. When the form displays, each Checkbox's tag get populated with 1,2,4,8,16,32 etc etc. If I'm right, when adding up these values (based on the selection) you'll get a unique integer fro every possible combination. So ok, lets say I selected 1,2 and 8 then I get 11. So now I return this value to the calling form -> but how do I get abck to 1,2 and 8 from 11. I'm stumped. thanks in advance.
    :
    :
    :
    Use the and-operator:
    [code]
    CheckBox.Checked := Value and CheckBox.Tag = CheckBox.Tag;
    [/code]
    This will filter the correct bit and make the box checked, if that bit is set.
  • albertinixalbertinix Member Posts: 1
    : : [b][red]This message was edited by dve83 at 2007-3-18 7:15:21[/red][/b][hr]
    : : Hi, my head's not on straight it seems. I need to determine the unique selection of checkboxes. When the form displays, each Checkbox's tag get populated with 1,2,4,8,16,32 etc etc. If I'm right, when adding up these values (based on the selection) you'll get a unique integer fro every possible combination. So ok, lets say I selected 1,2 and 8 then I get 11. So now I return this value to the calling form -> but how do I get abck to 1,2 and 8 from 11. I'm stumped. thanks in advance.
    : :
    : :
    : :
    : Use the and-operator:
    : [code]
    : CheckBox.Checked := Value and CheckBox.Tag = CheckBox.Tag;
    : [/code]
    : This will filter the correct bit and make the box checked, if that bit is set.
    :
    This is very wrong. I'm referring to the idea. How can you believe that you can extract the checkboxes - if you only pass a number to the calling form? It's impossible. Theoretically - there are infinite possibilities.
    Let me give you just an example: say you pass to the calling form the number 11; this number can be obtained if you checked boxes no. 3 and 8, or boxes no. 2 and 9, or 1 and 4 and 6, or 2 and 4 and 5, and so on....
    Obviously - the possibilities aren't infinite in this particular case, but the higher the number, the higher the possibilites.
    In conclusion - you cannot obtain the original checkboxes from that number. (in a very simplist way, this is the way a hash function runs; it obtains a result, but theoretically there are infinite possibilities to obtain that result).


  • zibadianzibadian Member Posts: 6,349
    : : : [b][red]This message was edited by dve83 at 2007-3-18 7:15:21[/red][/b][hr]
    : : : Hi, my head's not on straight it seems. I need to determine the unique selection of checkboxes. When the form displays, each Checkbox's tag get populated with 1,2,4,8,16,32 etc etc. If I'm right, when adding up these values (based on the selection) you'll get a unique integer fro every possible combination. So ok, lets say I selected 1,2 and 8 then I get 11. So now I return this value to the calling form -> but how do I get abck to 1,2 and 8 from 11. I'm stumped. thanks in advance.
    : : :
    : : :
    : : :
    : : Use the and-operator:
    : : [code]
    : : CheckBox.Checked := Value and CheckBox.Tag = CheckBox.Tag;
    : : [/code]
    : : This will filter the correct bit and make the box checked, if that bit is set.
    : :
    : This is very wrong. I'm referring to the idea. How can you believe that you can extract the checkboxes - if you only pass a number to the calling form? It's impossible. Theoretically - there are infinite possibilities.
    : Let me give you just an example: say you pass to the calling form the number 11; this number can be obtained if you checked boxes no. 3 and 8, or boxes no. 2 and 9, or 1 and 4 and 6, or 2 and 4 and 5, and so on....
    : Obviously - the possibilities aren't infinite in this particular case, but the higher the number, the higher the possibilites.
    : In conclusion - you cannot obtain the original checkboxes from that number. (in a very simplist way, this is the way a hash function runs; it obtains a result, but theoretically there are infinite possibilities to obtain that result).
    :
    :
    :
    He clearly stated that he intends to use a binary storage method to store the individual boolean values into an integer. That is not only possible but also commonly used in computers.
Sign In or Register to comment.