Retrieve TestStand™ Variable Names Programmatically

Updated Sep 24, 2026

Reported In

Software

  • TestStand
  • LabWindows/CVI
  • LabVIEW

Programming Language

  • C# .NET

Issue Details

I want to programmatically get a list with the names of my TestStand variables (i.e. Locals, Parameters, FileGlobals, StationGlobals) from my code module. How can I do this?

Solution

You can use two TestStand API methods defined in the PropertyObject class:

 

  • PropertyObject.GetNumSubProperties: This method returns the number of subproperties belonging to a particular object (e.g. number of local variables, sequence file globals, subproperties of a TestStand container, and so on). You can then have a loop with as many iterations as the number of subproperties to get the name of each variable using the PropertyObject method described next
  • PropertyObject.GetNthSubPropertyName: This method returns the name of a subproperty that the index specifies.

 

How to correctly use these methods and pass them the correct reference depends on how your code module is called:

 

  • If the code module is called from a step in a sequence you need to pass the SequenceContext to your code module and use it as the ActiveX reference for the PropertyObject methods described above. Please refer to the following instructions, based on your development environment:
    • ​In LabVIEW, you must first call the SequenceContext.AsPropertyObject method and use the return value as the ActiveX reference for the PropertyObject methods. Pass one of the following values to the lookupString parameter: Locals, Parameters, FileGlobals or StationGlobals, depending on the scope of the variables you want to obtain. Do not use quotes in LabVIEW.
    • In LabWindows/CVI, your code might look like:
// Get the number of Local Variables 

tsErrChk (TS_PropertyGetNumSubProperties (testData->seqContextCVI, &errorInfo, "Locals", &NumOfSubproperties));

for (Index = 0; Index < NumOfSubproperties; Index++)
{ 
// Get the Nth variable name and store it in the variable called "VariableName" 
tsErrChk (TS_PropertyGetNthSubPropertyName (testData->seqContextCVI, &errorInfo, "Locals", Index, 0, &VariableName));
}
  • In .NET, obtain the Locals object using the Sequence.Locals property and then use the PropertyObject methods described above.
  • If your code module is not called from any sequence or you need the reference to variables defined in a sequence file other than the one calling your code module, then you will not have the SequenceContext available. In this case, you can use the following methods and properties to get an object to be used as the reference for the two PropertyObject methods listed above:

 

Once you obtain the Locals, Parameters, FileGlobals, or StationGlobals PropertyObject, use that object as the ActiveX reference when calling GetNumSubProperties() and GetNthSubPropertyName(). When using the object directly, pass an empty string ("") to the lookupString parameter.

Additional Information

The GetNumSubProperties() and GetNthSubPropertyName() methods can be used with any PropertyObject container, not only variable collections. This allows programmatic enumeration of subproperties in custom containers and other TestStand objects.