NI TestStand

Showing results for 
Search instead for 
Did you mean: 

Need help with Test Stand Logic Formula

Go to solution

I have:

Locals.TestBool = (Locals.Value != (1||2) ? True: False)


When the value is 1, it returns False.  But if the value is 2, it returns True.  Does that not work as I expect?  Not a traditional OR?  Am I missing something?  Is that not actually saying If Locals.Value Does NOT Equal 1 OR 2, then True?  Why does it return false for only 1?


0 Kudos
Message 1 of 3
Accepted by topic author DailyDose

|| causes a Boolean OR.  1||2 will result in a TRUE.  Now that TRUE has to be converted into a numeric to compare to your number, which will be a 1.  So 2 does not equal 1, therefore your result is TRUE.


What you really need here is:

Locals.TestBool = (Locals.Value != 1) && (Locals.Value != 2)

With this setup one of the intermediate values will be a FALSE if Value is a 1 or a 2.  You need to then AND those values to get the result you want.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3

Ahhhh.... Thank you!   This feels like a newby mistake.  Much appreciated.

0 Kudos
Message 3 of 3