NI TestStand

Showing results for 
Search instead for 
Did you mean: 

How to auto rename teststep in loop

Go to solution



in the attached sequence i am renaming a teststep in a loop.

The new stepname should be the old stepname + a prefix which is the loopcounter

So old name is: 123

New names should be

loop: 1 - 123

loop: 2 - 123

loop: 3 - 123


But the sequence creates:

loop: 1 - 123

loop: 2 - loop: 1 - 123

loop: 3 - loop: 2 - loop: 1 - 123


Any idea how to solve this?



0 Kudos
Message 1 of 7



Maybe this helps





NIWeek 2017: Standardized HIL Test Automation With TestStand
NIWeek 2016: Capturing ATE Requirements With Requirements Gateway

Feedback or kudos are welcome
Message 2 of 7

You need to store the original name in a temp variable and restore it after the step has executed.  During run time, the step saves its name, which is why the step name continues to grow in your loop.


This is also discussed in several threads, such as this one:


Pulido Technologies LLC

Message 3 of 7


thanks for the link and the idea of the temp-variable.

I got another idea:

What if i call the default teststep: "Loop: x - 123"


And the "Change Step name" should take the NextStep.Name, then cut everything up to the "-" (something like fromthrough(0, "-") and paste the new loop-text before the rest. And if all loops just cut the old text up to the "-" it should work.

Question is only how to do the cut&paste thing in the expression...

0 Kudos
Message 4 of 7

That would work too.  I would use a combination of Mid and Find.  This expression would work, but you may need to tweak for your specific needs:

Mid(RunState.PreviousStep.Name,Find(RunState.PreviousStep.Name," - ")+Len(" - "))


The Find function finds the index of the dash in the previous step name and also adds the string of the dash.  The Mid function will split the string at that index.


Pulido Technologies LLC

Message 5 of 7


Works perfect.

"Loop: " + Str(Locals.i)  + " - " + Mid(RunState.NextStep.Name,Find(RunState.NextStep.Name," - ") + Len(" - "))

Thx a lot

0 Kudos
Message 6 of 7
Accepted by topic author OnlyOne

You can use:

"Loop: " + Str(Locals.i)  + " - " + (Find(RunState.NextStep.Name," - ")<0?RunState.NextStep.Name:Mid(RunState.NextStep.Name,Find(RunState.NextStep.Name," - ")+Len(" - ")))


The comparison is needed because the first run doesn't have a dash in it. 


Pulido Technologies LLC

Message 7 of 7