09-29-2009 09:57 AM
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.
Solved! Go to Solution.
09-29-2009 09:59 AM
Can't be done without scripting... use a ring.
Ben
09-29-2009 10:02 AM
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.
09-29-2009 10:07 AM
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
09-29-2009 10:08 AM
Got it...thanks.
H
10-20-2009 03:25 PM
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:
10-20-2009 03:33 PM
10-20-2009 04:44 PM
Sorry. Here's a demo vi in LV8.5.1
10-20-2009 07:57 PM
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.
10-20-2009 09:14 PM
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. 😉