From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop with Status Expression to Fail the Loop

I'm trying to get a While Loop step to throw a Pass/Fail.

Basically we want to loop on some steps a max of 'X' number of times.

If the Loop condition goes False before the set number of iterations, we want the step to Pass.

If not, we want it to Fail.

It's a Loop Timeout based on the loop counter.

 

I've created a custom While Loop step with the Status Expression enabled so we can build an expression.

 

For testing, the While Loop Condition is simply "RunState.LoopIndex < 10"

The Status Expression is "RunState.LoopIndex == 10 ? Step.Result.PassFail = Evaluate(RunState.LoopIndex == 10) : False, Step.Result.PassFail ? "Passed" : "Failed" "

 

When this runs, the opening While step immediately fails, presumabely due to RunState.LoopIndex not equaling 10. This seems to override the Loop Condition statement.

 

Is this even possible or do I need to build some other logic to make this work?



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 1 of 2
(4,662 Views)

Have you considered puting the steps you wnat to loop on in a sequence that returns a True/False boolean and then calling that sequence using a custom loop?

 

You can then set the Loop while expression to "RunState.LoopIndex < 10 && RunState..RunState.LoopNumPassed < 1"

 

I hope this helps.

 

-Jack

0 Kudos
Message 2 of 2
(4,639 Views)