How Do I Programmatically Change the Entries of an Enumerated Type?

Updated Sep 29, 2018

Reported In

Software

  • LabVIEW

Issue Details

How do I programmatically change the entries of an enumerated type?

Solution

You cannot programmatically change the type (the strings) of an enumerated data type, just as you cannot programmatically change an integer control into a double or a string control into a path control. The strings in an Enum are a part of its data type and thus can only be changed during edit time. It is possible to read the strings of the Enum through a Property Node, but you cannot write them using a Property Node.

If you choose to write to the Strings property of an Enum during runtime, you will see Error 1073 occurred at Property Node as shown below:
 

Additional Information

If you want to programmatically change the text values in the Enum, use a text ring control instead. You can use the ring control to programmatically read and write the strings through the Strings property.

Note: If you have a large array of strings that you would like to populate an Enum with, you can simply replace the Enum with a text ring by right clicking on the Enum and selecting Replace and selecting the text ring. Create a property node to write to Strings and then run your program to write the string array to the property node. This will populate the text ring. Once the text ring is populated, you can "Replace" it with an Enum and it will retain all of the values from the text ring.

WAS THIS ARTICLE HELPFUL?

Not Helpful