NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to auto rename teststep in loop

Solved!
Go to solution

 

Hello,

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?

 

Thx

0 Kudos
Message 1 of 7
(4,187 Views)

Hi

 

Maybe this helps

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 2 of 7
(4,183 Views)

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:

http://forums.ni.com/t5/NI-TestStand/Trying-to-dynamically-change-a-step-name-during-execution-but/t...

 

Pulido Technologies LLC

Message 3 of 7
(4,182 Views)

Hello,

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
(4,177 Views)

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
(4,171 Views)

Edit.

Works perfect.

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

Thx a lot

0 Kudos
Message 6 of 7
(4,168 Views)
Solution
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
(4,159 Views)