LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure with different boolean

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.

0 Kudos
Message 1 of 10
(4,148 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,139 Views)

Hello,

You need to place 3 boolean constant on each case. Every case will have one boolean constant true then just wire it out. 


CLD Using LabVIEW since 2013
0 Kudos
Message 3 of 10
(4,130 Views)

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...

0 Kudos
Message 4 of 10
(4,111 Views)

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.

0 Kudos
Message 5 of 10
(4,107 Views)

@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

0 Kudos
Message 6 of 10
(4,093 Views)

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.

0 Kudos
Message 7 of 10
(4,091 Views)

@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 Smiley Indifferent? 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...

 

0 Kudos
Message 8 of 10
(4,085 Views)

@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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 10
(4,073 Views)

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).

0 Kudos
Message 10 of 10
(4,035 Views)