LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean selection and conversion to numeric

I currently have 3 different boolean values being produced by my program. At any 1 time, only 1 of them is equal to 1 and the others are equal to 0. I want to have a case statement which I can use to create a different numeric value based on which boolean value is equal to 1. How can I differentiate between the boolean values in order to use them in my case structure?

 

Note: Once i have the right case selected the number will be sent to RobotStudio.

0 Kudos
Message 1 of 4
(159 Views)

Try this snippet:
Convert Booleans to Number for Case Structure.png

 

or this one if you're feeling mathy:
Convert Booleans to Number for Case Structure_Log2.png

 

Here's a simple implementation, but it doesn't catch the error condition where more than one Boolean is True:
Search 1D Array.png

 

There's lot's of ways your code can find which Boolean is True. Which way makes the most sense to you?

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 2 of 4
(151 Views)

@jrossy_1191 wrote:

I currently have 3 different boolean values being produced by my program. At any 1 time, only 1 of them is equal to 1 and the others are equal to 0. I want to have a case statement which I can use to create a different numeric value based on which boolean value is equal to 1. How can I differentiate between the boolean values in order to use them in my case structure?

 

Note: Once i have the right case selected the number will be sent to RobotStudio.


How about something like this?

 

BoolSelect.png

 

  1. When only Boolean 1 is True send 100 
  2. When only Boolean 2 is True send 200
  3. When only Boolean 3 is True send 300
  4. All other Boolean combinations send nothing
========================
=== Engineer Ambiguously ===
========================
Message 3 of 4
(93 Views)

@jrossy_1191 wrote:

I currently have 3 different boolean values being produced by my program. At any 1 time, only 1 of them is equal to 1 and the others are equal to 0. I want to have a case statement which I can use to create a different numeric value based on which boolean value is equal to 1. How can I differentiate between the boolean values in order to use them in my case structure?

 

If only exactly one boolean must be true, I recommend to use a radio button instead.

 

altenbach_0-1747421003845.png

 

Message 4 of 4
(74 Views)