NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does my conditional expression not work?

I want to increment a global keeping track of how many critcal tests have been run. Usually I just increment it in the post expression of the test. However, if I have a test that loops it would increment on every loop, so I put a conditional expression in the post expression so it only counts once the loop is done:

RunState.LoopIndex < 10 && RunState.LoopNumPassed < 3 ? FileGlobals.Critical_Test_Count : FileGlobals.Critical_Test_Count++

However, the false condition in the expression never gets evaluated. I've put watches in to make sure the condition goes false after the last interation of the test and it does. But my global never increments. The true condition is not supposed to modify the variable.

What am I miss
ing?
0 Kudos
Message 1 of 3
(3,791 Views)
The reason for this is that the post expression is evaluated before the loop increment expression, so on your last loop the post expression is evaluated (loop count = 9) then the loop increment is evaluated and the loop is terminated. See page 6-26 of the Teststand user manual.

Hope this helps,
Nick
Message 2 of 3
(3,791 Views)
Thanks Nick, I guess I took the "Post" term to literally; that it was last action done.

From the Manual, the post action step is done after the loop expressions, so for both a "On Pass" and "On Fail" I call a sequence which only increments the variable. Not very elegant, but it works.
Message 3 of 3
(3,791 Views)