Example Code

Programmatically Create Enumeration Variable in TestStand

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW
  • Teststand

Code and Documents

Attachment

Download All

Description

This example shows you how to programmatically create an enumeration variable using the TestStand API.

 

How to Use

1. Create a property object with value type Container using the NewPropertyObject Method:

2. Then define a name for the property object and the number of elements it will contain using the Name Property and SetNumElements Method:

3. After, you can populate the property object, each element in the container should have two sub properties: EnumeratorName and EnumeratorValue that you can add using the NewSubPropery and SetValString and SetValNumber respectively methods:

4. You should create also a new data type using the NewDatatType method and name it using Name Property:

5. By default, the data type is empty, to populate it you can use the Update enumerators method passing the reference of the created container:


6. Finally, you can insert the enum data type in the type usage list of the current sequence file using the InsertType method, use the IncChange Count method required to indicate to the sequence editor or user interface that the file was modified and the SaveFileIfModified method to save the changes in the sequence file.

7. To create a instance of the enum data type you can use the NewSubProperty method, for example to create a local variable:

Note: The LabVIEW (2019) code described in this document is provided as attachment.

 

Additional Information

​​​​​​If you are interested in creating a data type refer to Using the TestStand API to create a Data Type.

 

Related Links

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Member
Member
on

Clear and detailed explanation on creating an enumerated data type. Nice work!

Member
Member
on

Nice. Is it possible to update the Enum type without delete and create again?

Contributors