LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select case or event using a 2D Boolean array.

Solved!
Go to solution

Hi everyone,

 

I am trying to use a 2D Boolean array to select different events and/or cases. For example, if Boolean 1 and 2 are both TRUE, case 1 will be selected. If Boolean 1 is FALSE and 2 is TRUE, case 2 will be selected and so forth. I tried using the Boolean array to number but I need a way to differentiate between B1=TRUE, B2=FALSE and B1=FALSE,B2=TRUE. That is, no two Boolean combinations can lead to the same case/event.

 

~Mario

0 Kudos
Message 1 of 2
(2,600 Views)
Solution
Accepted by topic author M_Mario_M

You need to reshape your 2D array to 1D first.

 

Now, assuming you have less thant 64 array elements, "boolean array to number" will give you a unique number for each possible bit combination.

 


@M_Mario_M wrote:

I tried using the Boolean array to number but I need a way to differentiate between B1=TRUE, B2=FALSE and B1=FALSE,B2=TRUE.


 

As mentioned, each combination will give you a different value. You simply need to ensure that you add unique cases for each number. Add as many cases as you want to your case structure. If you don't, multiple patterns will trigger the default case.

 

If you still have problems, please attach your code.

Message 2 of 2
(2,595 Views)