LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie - How does one do a series of If-Then-Elses?

Solved!
Go to solution

This seems like a really basic question when transitioning from text based to LabView.

How does one handle the following in NXG? Basically sequential if then else?

 

If(condition A)

{

    Output Enum Value A

}

Else if(Condition B)

{

    Output Enum value B

}

...more else if's...

Else

{

    Output Enum C

}

 

My problem is my first condition gets a true/False

 

 

 

I could understand if one used a case with an Enum but how do I convert my Boolean logic into Enum values?

0 Kudos
Message 1 of 2
(1,253 Views)
Solution
Accepted by topic author flycast

You can do all your comparisons at once, combine it into a boolean array, then search for the first TRUE. Wire the output to the index of "index array" and have an array diagram constant of enums. If it is possible that none of the conditions match, add one to the index and make the first element the default output.

 

Here's a simple LabVIEW example. Should be easy to transpate into NXG.

 

altenbach_0-1602096887837.png

 

 

Another common "solution" is a deep stack of case structures (this should be "6.." to agree with the above code)

 

altenbach_0-1602097210950.png

 

 

0 Kudos
Message 2 of 2
(1,245 Views)