Getting the Name of Any TestStand Property Programmatically in TestStand

Updated May 3, 2018

Reported In


  • TestStand

Issue Details

How do I get the name of any TestStand property programmatically?  When I look under the Step or Sequence properties in the Expression Browser dialog box, there is no field for a Name property. For example, how do I get the name of the current step or sequence?  


There are four common methods of getting the name of any TestStand property programmatically. You can use the NameOf()function, the .Name object property,  AsPropertyObject().Name property or the TestStand API.

Additional Information

To use these functions and object properties, you will need a reference to the object for which you need the name. The following is a list of some property paths that refer to some of the common property objects:
Property Property Path to Use
Current Sequence File: RunState.SequenceFile
Current Sequence: RunState.Sequence
Current Step: Step or RunState.Step
Calling Sequence File: RunState.Caller.SequenceFile
Calling Sequence: RunState.Caller.Sequence
Calling Step: RunState.Caller.Step

Using the NameOf() Function
You can use this function if you need to access the name of a property from within an expression in a step (e.g. pre- or post-expression). The NameOf() function returns the name of any property object that is passed as an argument.
You can use one of the property paths mentioned above as the argument to pass. For example, you can use the following expression to get the name of the current sequence:

Locals.MySequenceNameVariable = NameOf(RunState.Sequence)

Where MySequenceNameVariable is a local string variable you can define to hold the name of the current sequence.

Using the . Name and  the AsPropertyObject().Name Properties
You can use the .Name property to access the name any property object or step, such as the ones listed above. If the object does not have a property for name such that you can use the .Name accessor, you can convert that object to a generic object by using the AsPropertyObject()method. The object will now have a property for name, which you can now access using . Name accessor.  The following is an example:

Locals.MySequenceNameVariable = RunState.Sequence.AsPropertyObject().Name 

Using the TestStand API
You can use the TestStand API if you need to access the name of a property from an external code module. First, you will need a reference to the object that references the property whose name you want to get, and then read the Name property defined in the object's class.

For example, if you want to get the name of the current sequence, you can get the property object that references the current sequence, ThisContext.Sequence  if you are passing the sequence context to your code module, and then read the Name property. Refer to your programming environment help for information about how to use ActiveX in order to properly access these properties.

For LabWindows/CVI, the following is an example of obtaining the object reference and then obtaining the name of that object:

TS_PropertyGetPropertyObject (testData->seqContextCVI, &errorInfo,"RunState.Sequence", 0, &CurrentSequence);

TS_PropertyGetProperty (CurrentSequence, &errorInfo, TS_PropertyName, CAVT_CSTRING, &SequenceName);


Not Helpful