From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement if then else?

Yes that will work.

But you can't change the limit value L while running.

Plus if X is a float you will have to think through the type casing to an Int that LabVIEW will do automaticly and set your limits wisely.

 

ElseThen.png

 

 

 

Omar
0 Kudos
Message 11 of 16
(1,452 Views)

What if i want a variable L in place of 6?

0 Kudos
Message 12 of 16
(1,428 Views)

You can't.  Just implement something like Jcarmody showed in reply #6 where you do the multiple tests, convert them to a boolean array which you typecast to a number, that you put into the case structure.

 

I think the one error he had in his example was that he had L = -2, and by the logic he used and you asked for, leads to invalid results.  L should always be a positive number.

Message 13 of 16
(1,401 Views)

If the Case Structure is "the box" I would think outside of it in this case.

 

StepFunction.png

0 Kudos
Message 14 of 16
(1,388 Views)

Thank you. I didn't know such a trick (answer n.6 booleean array to number) to avoid multi-nested case. 

0 Kudos
Message 15 of 16
(1,066 Views)

Today I learned the Step function can literally be replaced with two primative functions (greater than or equal 0 and boolean to 0 and 1).

0 Kudos
Message 16 of 16
(1,026 Views)