07-03-2018 05:43 AM
Hi ,
I have case structure with 3 cases. For each case I want boolean button on/ off. This mean also if one case is on rest cases should be off. Any idea and basic example for this.
07-03-2018 06:03 AM - edited 07-03-2018 06:04 AM
Hi WatFin,
when your case structure has 3 cases you cannot use a boolean to select one of 3 cases.
Instead you need to use a numeric value (or enum) for selection!
Build an array from your 3 booleans, then convert the boolean array to number. Set the case selctor values according to the bit values. (Setting the radix of the case selector to boolean might help here, too.)
Any idea and basic example for this.
Search this forum for similar questions. I'm pretty sure you will find examples…
07-03-2018 06:09 AM
Hello,
You need to place 3 boolean constant on each case. Every case will have one boolean constant true then just wire it out.
07-03-2018 06:59 AM
If those Booleans come from the UI, consider making it a radio buttons control. That would automatically give you an enum with 3 values (4 if no selection is allowed), and you get the UI handling as a bonus.
3 Booleans result in 8 potential states, so you need to define what you want...
You can add the three Booleans to an array, and search for the first true. Wire the integer to a case...
07-03-2018 07:13 AM
Or convert the boolean array to a U8. The resulting integer number to a case structure. That allows you to have a case for any combination of Trues. If you change the display of the case structure dropdown to be be binary instead of decimal, it is easier to define the case with a combination of 1's and 0's for each true and false, rather than doing mental math to convert the True/false combination to a decimal number.
07-03-2018 08:05 AM
@RavensFan wrote:
Or convert the boolean array to a U8. The resulting integer number to a case structure. That allows you to have a case for any combination of Trues.
Yes, but that was already suggested
07-03-2018 08:07 AM
Yes. But you had searching for the first True. I added the option for all possible combinations in the event the person needed more than 1 true, or all 3 true.
07-03-2018 08:44 AM
@RavensFan wrote:
Yes. But you had searching for the first True. I added the option for all possible combinations in the event the person needed more than 1 true, or all 3 true.
Yes, like GerdW suggested in the 1st post ? I wasn't referring to my post...
@GerdW wrote:
Build an array from your 3 booleans, then convert the boolean array to number. Set the case selctor values according to the bit values. (Setting the radix of the case selector to boolean might help here, too.)
Not that important anyway, just didn't want OP to get confused...
07-03-2018 09:10 AM
@WatFin wrote:
Hi ,
I have case structure with 3 cases. For each case I want boolean button on/ off. This mean also if one case is on rest cases should be off. Any idea and basic example for this.
For the cursive part, use a Radio button and just wire a number out from each case to which button should ba Active.
/Y
07-04-2018 02:10 AM
Another option would be to have three cases, as each Boolean can be true or false. If they are unrelated, handling them should be unrelated. Ideally, that should be handled in an event structure (even if they are related).