10-01-2019 04:35 PM - edited 10-01-2019 04:36 PM
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.
Regards
Jack
10-01-2019 05:22 PM
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.
10-01-2019 08:03 PM - edited 10-01-2019 08:03 PM
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.
10-02-2019 04:58 PM
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
10-09-2019 11:29 AM - edited 10-09-2019 11:30 AM
If you wired up the error cluster...you'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.
10-09-2019 11:53 AM
@MrJackHamilton wrote:
If you wired up the error cluster...you'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.
10-09-2019 12:27 PM
The ring control should be used instead of the enum when doing this.
10-09-2019 12:31 PM
@OregonGumby2 wrote:
The ring control should be used instead of the enum when doing this.
If only someone could create a thread describing how to do that 😉
10-09-2019 12:47 PM
@cbutcher wrote:
@OregonGumby2 wrote:
The ring control should be used instead of the enum when doing this.
If only someone could create a thread describing how to do that 😉
08-08-2024 07:19 AM
Hello ,
Here an example of programmatically fill the elements of enum
programmatically. for enum controls the data cannot be fille during exection , the this vi is open the cotrol from another VI and adding the data 🙂