NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

request 0 or 1 best opportunity

Hi,

 

I want to request if a scanned variable is 0 or 1.

When 1: next step

When 0: false, call sequence or something like that

 

What´s the best oppurtinity to check it?

If/else?

Expressions?

Extra Statement Step?

 

Kind Regards,

Andreas

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

For me it would come down to the number of steps I wanted to run (or not run) depending on the state of the variable.  If it were a single step then I would go for a PreCondition (see PreConditionBuilder) on that step, for multiple steps I would go for an If/else. 

 

NOTE:  PreConditions are cool, but you sacrifice a little readability.

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

Hi,

 

thanks for your reply. But the Preconditon expected Boolean, but found a Number (because my variable is a number variable with 0 or 1).

Can I "Change" the numbers into a boolean?

 

Kind Regards,

 

Andi

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

Hi Andi

 

Yes, a PreCondition evaluates an expression that needs to result in a Boolean.  For your purposes (numeric), your PreCondition needs to be an expression that tests the value of your numeric in a way that gives you a Boolean result.  Here are a few PreCondition examples hopefully one will suit you purposes:

 

Locals.YourVariableHere == 0 (Run the step if your variable equals 0)

Locals.YourVariableHere != 0 (Run the step if your variable does not equal 0)

Locals.YourVariableHere > 0 (Run the step if your variable is any positive number greater than 0)

Locals.YourVariableHere <= 4 (Run the step if your variable is less than or equal to 4)

(Locals.YourVariableHere == 1) || (Locals.YourVariableHere > 3) (Run the step if your variable is equal to 1 or is greater than 3)

 

Regards

 

Steve

0 Kudos
Message 4 of 5
(2,569 Views)

Hi Steve,

 

thanks, it helps me a lot.

 

Regards

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