NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

String value Test Pre Expression

Hi 
I have a String result test that checks a revision string. As the revision can change I made the test limit and result the same, so the test passes. However I need to handle the exception when the limit and result is empty. 

To do this I was thinking to use the pre expresion field to fail the test when the result is empty. But my coding skills aren't good enough.

Open to better ideas, and hope this explains the situation clear enough.

Hence he call for help.

 

0 Kudos
Message 1 of 5
(1,304 Views)

Hi RN888,

 

I think I understand what you mean.  What about configuring the Limits of your String Test as shown below?  

 

TestStand1.JPG

 

If the value returned from your test is an empty string then that is compared against "" (an empty string) test limit (and passes), otherwise the value return is compared against your expected version number (I have used "Version 1.0").

 

NOTE:  The statement uses the Ternary Operator (the ?).  It is a conditional expression.  If the statement in the brackets (Step.Result.String == "") evaluates to TRUE then the bit to the left hand side of the ":" is used, otherwise the bit to the right-hand side of the ":":is used.

 

Hope this helps

 

Steve

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

Hi,

One way of doing it is given below :

Add a numeric limit step.

Configure it as below :

RaviShrigiri_0-1644572277800.png

In the data source tab :

Len(Locals.str)

 

If the string length of your string is >0  i.e. string not empty then it willl pass else fail.

 

Ravi

 

0 Kudos
Message 3 of 5
(1,268 Views)

Thanks Steve

Apologies for not getting back sooner. I was job jumped.  And NI Admin are asking for a response. The conditional operator is what I need. I would supply you with working my solution, but I can't test it at the moment. TestStand 2020 is not showing variables correctly in the watch window. Yet they are showing in my logs. Something weird going on, but I digress.  Thanks again. 

 

My rough draft is either

In Limits
Locals.Rev_Limit = ( (Locals.PEBB_Recovery_Kernel_Rev == "" ) ? "No Rev" : Locals.PEBB_Recovery_Kernel_Rev )

 

or my prefered response which is a better representation of what happened.
In Module/Results

Step.Result.String = ( (Locals.PEBB_Recovery_Kernel_Rev == "" ) ? "No Rev" : Locals.PEBB_Recovery_Kernel_Rev ) 

This should give a result of 2.1.0.8 or No Rev

0 Kudos
Message 4 of 5
(1,226 Views)

I ended up doing this. It is not as elegant as I wanted, but it does the job.

 

RN888_0-1645585926404.png

And used the first VI  Fail Mode pre expresion to force the results,

and did not write to Step.Result.String in the Module

 

RN888_1-1645586066563.png

And then forced the Limits to an empty string

RN888_2-1645586272436.png

 

I did try to use a pre expression to determine which of the two would execute

But this created unwanted 'skipped' logging in our database, hence I went with the IF

solution

 

0 Kudos
Message 5 of 5
(1,215 Views)