NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Operator not working as expected

Solved!
Go to solution

Using a Numeric Limit Test in TestStand, and in the Post-Expression I have the following:

Step.Result.ReportText = Step.Result.Status == "Passed" ? "" : Step.Result.ReportText + Str (Step.Result.Numeric),
FileGlobals.ErrorMessage = Step.Result.ReportText

 

I have the Step.Result.ReportText being read in a property loader with no issues.

However, I figured if the Step.Result.Status was equal to "Passed", the expression would set the Step.Result.ReportText to null and not report anything. I've stopped the step and verified the Status is Passed, but it continues to report the message loaded.

0 Kudos
Message 1 of 4
(3,945 Views)
Solution
Accepted by topic author sdrochek3

I believe this will be due to the order in which the actions forming the step are performed. Looking at Step Execution in the TestStand 2016 Help, it indicates that the post-expression is evaluated before the status expression. This will mean that the Step.Result.Status value will not be available at the time the post-expression is evaluated.


Message 2 of 4
(3,913 Views)
Solution
Accepted by topic author sdrochek3

Hi sdrochek3

In TestStand the PostExpression is carried out before the StatusExpression which is what populates Step.Result.Status.  When your PostExpression executes Step.Result.Status will be an empty string (!= "Passed") so it always hits the failed element of your conditional operator.

Steve

Message 3 of 4
(3,912 Views)

Try the following in the post-expression:

Evaluate(Step.TS.StatusExpr) == "Passed" ? ("Do the Passed-Thing"):("Do the Not-Passed-Thing")

 

The status-expression is evaluated now in post-expression as well.

0 Kudos
Message 4 of 4
(1,719 Views)