LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing items from a text file to enum

Hello, 

I have a text file with multiple items in it. I don't want to write each and every item in the enum manually. Is there any easy or shorter way of writing/importing these items directly into an enum ?

 

Thanks in advance. ☺️

0 Kudos
Message 1 of 3
(376 Views)

Are you looking at defining an enum at edit-time or run-time?

 

If at run-time, you should be using a Ring.  You can set the values for a ring using a property node with the Strings[] or the Strings and Values[] property.

 

If at edit-time, then you can do something similar, but you will need to use "scripting", which would require getting a reference to the enum from another VI in order to update the values.

 

 


GCentral
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 2 of 3
(367 Views)

@crossrulz wrote:

Are you looking at defining an enum at edit-time or run-time?

 

If at run-time, you should be using a Ring.  You can set the values for a ring using a property node with the Strings[] or the Strings and Values[] property.

 

If at edit-time, then you can do something similar, but you will need to use "scripting", which would require getting a reference to the enum from another VI in order to update the values.

 

 


I think the major roadblock is that you cannot edit strings and values of an enum while the VI is running.  But you can get around this.  You could create the enum in VI #1, create the code to auto-populate your enum in VI #2, working with a reference from the control in VI #1.  That way, VI #1 isn't really running, so you can modify the properties.  I've done it before, so it's more than just a theory.  It's not my idea - I saw it here somewhere...

 

Edit:

I forgot an easier way is to auto-populate a ring, then replace it with an enum.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 3
(333 Views)