LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

if statement implementation

Hi everyone.  I have been looking for a way to implement an "if" statement for a while now on my programs with no success, so I was just wondering how people do this in LabVIEW.  For example, I have 2 different streams of data coming in (hex format) and would like to do seprate things with it.  Normally, I would write a program to say:

 

x = aa; 

y=bb;

 

if (data == x)

  then perform computations on this x data

 

else

if(data == y)

  then perform computations on this y data

 

However, the case structure seems to only work on boolean values.  How would one go about writing this code?  Can I implement some sort of comparison vi which triggers a true/fase switch?  Thanks very much.

0 Kudos
Message 1 of 5
(2,417 Views)

You can wire a string to a case structure. You can also wire integers. You need a default case or you will get an error. You do not need a default for a boolean as long as you have two cases and you do not need a default for an enum (integer) if you have a case for each item in the enumeration.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 5
(2,414 Views)

If your data is a "short" string you can connect it directly to the selection terminal of the case structure and then create case for each value you want to be able to catch PLUS a default case for all other value.

If it's the same with decimal numbers.

If you data type is different then you have implement a more complexe condition detection.

 

Tell us more about your data type so we can tell you what the best option is.

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 3 of 5
(2,407 Views)

You stated "I have 2 different streams of data coming in "

Since LabVIEW is a dataflow language you do not need to determine wheather the data is sourced from X or Y but simply wire the x data to the x process and the y data to the y process.

 

Case structures work with most base data types booleans, strings, integers and the error cluster (which it treats specially as a boolean) .  Look at the state machine design pattern for examples (File>>New...\Vi \Framworks\Design Patterns\ Standard State Machine)


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(2,404 Views)

Got it, thanks everyone.  I am writing it now, if I have any questions I will be sure to post my program.  Thank you.

0 Kudos
Message 5 of 5
(2,396 Views)