NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I put more than one statement into a Condition in TestStand

I'm trying to learn to use the Conditional statement in more than it's simplest form and I have 2 questions:

Question 1:
For instance simple statement is:
Locals.nValue=(Locals.Compare>5) ? 1 : 2

However, I want to do 2 things in the Condition
Locals.nValue=(Locals.Compare>5) ? 1,Locals.sString = "Yes" : 2, Locals.sString = "No"
But, this doesn't work (using the comma separator). Is there a way to put 2 statements into the conditional case?

Question 2:
For a series:
Locals.nValue=(Locals.Compare>5) ? 1 : Locals.nValue
Locals.nValue=(Locals.Compare<=5)? 2 : Locals.nValue
Also, is there a way to do NOTHING in the Else? (The folowing was suggested in the TestStand class that I took but
it doesn't work:
Locals.nValue=(Locals.Compare>5 ? 1 : NOTHING
This makes "Locals.nValue" = Nothing and I find that I can't leave the "False" condition blank.

Mike
0 Kudos
Message 1 of 2
(2,987 Views)
Mike -
1) You wanted to do something like this:
Locals.nValue=(Locals.Compare>5) ? 1,Locals.sString = "Yes" : 2, Locals.sString = "No"

You can do this like this:
Locals.nValue=(Locals.Compare>5) ? (Locals.sString = "Yes", 1) : (Locals.sString = "No", 2)

By using the parethesis, the parser assumes that last element in the list is the final value to be "returned".


2) There is no way to do nothing in a conditional assignment. You wanted to do this:
Locals.nValue=(Locals.Compare>5 ? 1 : NOTHING

You have to assign the orginal value back to the target, like this:
Locals.nValue=(Locals.Compare>5) ? 1 : Locals.nValue

Scott Richardson (NI)
Scott Richardson
https://testeract.com
Message 2 of 2
(2,987 Views)