NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the name of a step in an expression

Hi,

I'm using TestStand to run a particular stepor a few selected steps using 'Run Selected Step' or 'RunSelected Step Using Single Pass'. In the setup section I would like to know the name of the first step to be executed.

1) Can you show me how to do it in an expression (TestStand level)
2) How to do in a CVI code?

Thanks
Rafi
0 Kudos
Message 1 of 9
(4,172 Views)
Hi,

To answer the first part.

try 'NameOf(RunState.InitialSelection.SelectedSteps[0])'
so to save the answer to a string variable in locals.

Locals.FirstStepName = NameOf(RunState.InitialSelection.SelectedSteps[0])

You can also test to make sure something is selected, encase its part of same sequence either run complete or part of.

use Exist("RunState.InitialSelection.SelectedSteps[0]") in the precondition of the step.



To answer the second part
try TS_StepGetProperty(StepRef, NULL, TS_StepName, CAVT_CSTRING, StepName);

You would need to obtain a ref to the Step and hold in StepRef and the result will be returned in StepName.

Regards
Ray Farmer

Message Edited by Ray Farmer on 06-07-2005 12:48 PM

Regards
Ray Farmer
0 Kudos
Message 2 of 9
(4,174 Views)
Hi Ray,

Thank you very much.

Another question in a similar issue: In a Multiple Numeric Limit test, is there a field (in the Context) that indicates how many tests are there?

Thanks
Rafi
0 Kudos
Message 3 of 9
(4,151 Views)
Hi,

The only way I know off is to check the size of the array.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 9
(4,147 Views)

Hi Ray,

I"m trying to use this mechanism and it doesn't work!

1) Exist is not recognized by TestStand

2) I'm using the following precondition in a step in the setup section called "testing" --
NameOf(RunState.InitialSelection.SelectedSteps[0]) != "Status"

where "Status" is the name of the step in the main sequence.

I select "Status" test and execute --   'Run Selected Step using Single Pass'

I get  the following error: 

The precondition for the step 'testing' could not be evaluated.
Wrong number of array indices.
Error in argument 1, 'RunState.InitialSelection.SelectedSteps[0]', in call to the expression function 'NameOf'.

3) I explain again the purpose of what I'm doing:  I want to be able to select any combination of steps in the main Sequence' section.  Then, I want to use a precondition base on the first step of the group I have selected.  This precondition will be used in a step in the seup section..
 
Thanks for helping
Rafi
0 Kudos
Message 5 of 9
(4,082 Views)

Hi Rafi,

RunState.InitialSelection.SelectedSteps is only populated when you do Run Selected Steps not when using Run Selected using Single Pass.  When you use Run Selected Steps with Single Pass use RunState.Root.Runstate.InitialSelection.SelectedSteps.

So to be on the safe side, using NameOf(RunState.Root.RunState.InitialSelection.SelectedSteps[0]) will work in both cases since they are both populated in either scenarios.

I hope this helps

SijinK

National Instruments

0 Kudos
Message 6 of 9
(4,066 Views)
Hello Sijinik
 
As far as I can see, you CAN'T do   RunState.Root.RunState.InitialSelection.SelectedSteps[0]) 
You can't go deeper than   RunState.Root.
 
Am I missing something?
 
Thanks
Rafi
0 Kudos
Message 7 of 9
(4,030 Views)

(continue....)

Surprisingly, it does work !!

Now, I'm even more confused.....

can you explain this statement please ?   (actually only the first part  RunStat.Root.RunStat......)

 

Thank you

Rafi

0 Kudos
Message 8 of 9
(4,025 Views)

Hi Rafi,

Runstate.Root.Runstate is a field that is populated only at runtime. So at development time, the expression might seem to have an error. You can find this property, if you place a breakpoint in your sequence and run it. Then click on the context tab and you can see a lot more fields/properties than you had during development.

Glad to know it works

SijinK

National Instruments

0 Kudos
Message 9 of 9
(4,016 Views)