LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you set the value of an enumeration programatically

Solved!
Go to solution

I would like to be able to select (programatically) the value of an enumeration.  I don't seem to be able to find any reference to how to do that.

 

Thanks.

0 Kudos
Message 1 of 18
(11,351 Views)

Can't be done without scripting... use a ring.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 18
(11,346 Views)

Right...when you change the value(sngl) or value property...do you change it to the number of the ring slot (1,2,3...) or the Word that is in that slot...(Single, Double, Tripple...)?

 

Thanks.

0 Kudos
Message 3 of 18
(11,343 Views)
Solution
Accepted by topic author Hummer1

Hummer1 wrote:

Right...when you change the value(sngl) or value property...do you change it to the number of the ring slot (1,2,3...) or the Word that is in that slot...(Single, Double, Tripple...)?

 

Thanks.


 

Provided the property nodes is for a ring, you present it with the numric value. The text of teh ring is just a fancy graphic trick and has nothing to do with the ring's value (un-like enums where the numbers and strings are part of the data type).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 18
(11,336 Views)

Got it...thanks.

 

H

0 Kudos
Message 5 of 18
(11,330 Views)

hmmm....  maybe i didn't understand the question, but how come you can't use these methods "w/o scripting" to set or get the enums value:

 

enum.jpg 

Message 6 of 18
(11,236 Views)
Nice one...would you please make the label visible on the blocks you have used...?  Thanks.
0 Kudos
Message 7 of 18
(11,232 Views)

Sorry.  Here's a demo vi in  LV8.5.1

 

 

Message 8 of 18
(11,212 Views)

joshuatree wrote:

hmmm....  maybe i didn't understand the question, but how come you can't use these methods "w/o scripting" to set or get the enums value:


I think the question got misundersood. I believe Ben took it to mean to set the enumeration items rather than just writing a value to an indicator that's an enum. Setting the value of an enum indicator is the same as setting the value of any other indicator. Getting the enum value depends on what you mean by getting. In your example you're not "getting" the value of the enum. You're converting it to a string. That's a different operation. 

0 Kudos
Message 9 of 18
(11,198 Views)

True, True.  The original post wanted to know how to programmatically "select" the enum value.  To me, that means to either force the enum to display another value, or retrieve the current value.   I thought Ben was referring to the fact that you can't programmatically set or initiate new values into an enum.  Which as he said, can only be done with a Ring.

 

"In your example you're not "getting" the value of the enum. You're converting it to a string. That's a different operation."

 

I showed two ways to get the value,  one gets the current string value associated with the numeric value, and the other gets the current numeric value.  i went further in the attached vi, by demonstrating how to change the current (displayed) value of the enum by using a string.  (IFF you already know the string values in the enum.)   

 

In my program, i use a typedef cluster with an enum in it.  At runtime, i need to "select" the active enum value based on which operation i'm performing.  I know from elsewhere in the program what operation i need, but it's string, and there's no easy way to change the value of an enum with a string, except with the backdoor methods i showed.  

 

I wish my cohort woulda used a ring.  😉

 

 

0 Kudos
Message 10 of 18
(11,189 Views)