Showing results for 
Search instead for 
Did you mean: 

Load the String List of an Enum programmatically

It's possible to load a the string list of an Enum programmatically, in Development mode, [But not a runtime]

I use Enum ring controls quite a bit for state machines.

The Trick:

1. On a Front panel place a "Text Ring" control.

2. Using the 'Strings' Property node of the Text ring, load your list of strings. [Typically, I do this from a delimited file]

3. Once the Text Ring has the updated list, do the following:

4. Right-click on the Text Ring and select "REPLACE", browse the Controls menu to replace it with an 'Enum Ring'.

5. The Enum ring will now have the complete list from the Text ring.


...A work-around I know, but the forums say this is directly impossible.



Message 1 of 9

The impossible part is creating an enum at runtime.  What you explain is not even "programmatically".  That's using the LabVIEW UI, being able to swap controls, to your advantage.  But it does look like an easy method for populating a large list into an enum. 


Regarding state machines, I use the JKI State Machine, which uses strings for its state selector.  This allows you to add more than one state to the queue using multiline strings.  If you have not seen the JKI SM, I recommend that you check it out.

Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 9

Yes, you CAN do this programmatically.  You write the  array of strings to the Strings[] property of the enum.  But as you said, it can't be at "run-time".  it has to be in an enum control in a VI that is not running.


Message 3 of 9

Heck, that's not programmatic!  


I had an application that was "driven" by an Excel Spreadsheet.  The columns (there were about 160 of them, as I recall) specified the various (named) Parameters for the test, while the rows each represented a Test (with that row's set of Parameters).  We wanted an Enum that were the Names of all the Parameters, easily populated from Row 1 of that Spreadsheet.


Unfortunately, the students kept dreaming up more experiments that required additional (or different) parameters, so the Spreadsheet kept changing.  With 5-10 Parameters, you'd just edit the Enum, but with >100, you want a Programmatic way to create the Enum.  That's when I learned LabVIEW Scripting.  Open Spreadsheet, read and parse Row 1, then generate the Enum, giving it a name appropriate for the Spreadsheet Name/Version.  A great Time Saver and Error Eliminator.


Bob Schor

0 Kudos
Message 4 of 9

If you wired up the error'd see LabVIEW does not allow this. What is odd is that LabVIEW should.

My post was simply a 'quick-n-dirty' way to load a enum string list, without the development distraction of setting up LabVIEW scripting, or other work-arounds.





0 Kudos
Message 5 of 9

@MrJackHamilton wrote:

If you wired up the error'd see LabVIEW does not allow this. What is odd is that LabVIEW should.

No, it should not.  You are trying to update an enum while it is in a run state.  That definitely should not be allowed.  From another VI, you can get a reference to this VI and update the enum.  That is because then the VI with the enum will be in an edit state.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9