Update an Enum Variable in TestStand Using Expressions

Updated Oct 10, 2024

Environment

Software

  • TestStand

This article helps explain how you can update a variable in a Statement Step in TestStand when the variable is using an Enum custom data type.  To understand the example below on how to update an Enum variable, you will see Figure 1 below shows the Custom Data Type used which is "VISAEnum".  In Figure 2, you can see the values assigned to the data type that will be used in the steps below.
 
MyTypes.PNG
Figure 1. MyTypes.ini File
 
Figure 1 shows a Custom Data Type named "VISAEnum" that is an Enumeration data type created for this example.
 
EditEnumerators.PNG
Figure 2. Enumerator Strings with Values

Figure 2 shows the values for this VISAEnum data type to better understand the values that will be used in the following description.  For this example, the VISAEnum data type will be used for a Locals variable named "FlowControl".
 

1.  In the Expression field of the Statement Step type, use the Enum(String type, [String|Number] value) expression function to update an Enum variable.  In the Enum() function, String type refers to the Enum data type name and [String|Number value] refers to the value you want to update.  Figure 3 below shows how to use the Enum() expression function so that the FlowControl Enum variable will be updated.  The above example shows how to update the variable using the string value of the enumeration data type.

UpdateEnumUsingString.PNG
Figure 3. Updating Using String Value

 
2.  You can use either the String value of the Enum data type or the Numerical value of the Enum data type when using this expression.  Figure 4 below is now using the numeric value of the enumeration data type to update the FlowControl Enum variable.  This method does not require you to use quotation marks around the numeric value.
  
 
UpdateEnumUsingNumber.PNG
Figure 4. Updating Using Numeric Value

 

The images taken above are from TestStand 2020, there is a TestStand 2017 sequence file named "UpdateEnumVariable_2017.seq" attached at the bottom of this article which contains the above sequence so that it can be opened with TestStand 2017 or later.