LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Enum Text value from a Variant Control

Solved!
Go to solution

Hi

 

I was wondering what is the best way to get Enum text value from a variant control.

 

What I have is a subVI which has a variant control as an input and this VI is designed to read whatever is in the variant control and write it into a file. I have been using GetTypeInfo VI to get what datatype the Variant is and then based on that using Variant to Data function to extract the right data from them. This has worked well for most of the data types I need.

 

However for Enums while I can read out the numeric value quite easily by this method, I cant seem to get the text from them. I tried using the method from the solution posted here but since my control itself is of type LVVariant I can't seem to typecast it or change it to a more specific class of Enum. Although when I probe the LVVariant or flatten it to a string I can see that it does contain all the text data of the enum. What is the best way to get that?

 

Any ideas would be appreciated!

 

Thanks

 

Kewal

0 Kudos
Message 1 of 7
(6,488 Views)

As i understand you want to get the string from the Enum..!!Smiley Frustrated Correct?

 

2013-07-24_1753.png

Message 2 of 7
(6,475 Views)
Solution
Accepted by topic author kewsvnet

deep in the vilib:

VariantType.lvlib:GetNumericInfo.vi - Takes a Variant and returns the array of enum strings, throws error for non numerics.

Think this is what you are asking

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 3 of 7
(6,451 Views)
Message 4 of 7
(6,444 Views)

Hi

 

Thank you all for the replies!

 

Paul Falkenstein's solution was exactly what I was after, and I think I did try looking in that area but for some reason didn't look closer into GetNumericInfo, which now seems like quite the obvious VI to use.

 

Jiddu Krishnamurti that was an interesting solution, which I hadn't really known could be done but I think the other solution just seemed simpler to implement.

 

Mangesh D thanks for the reply although my problem was to do with getting the string from a variant rather than a simple enum control 

0 Kudos
Message 5 of 7
(6,437 Views)

NI keeps the good stuff burried.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 6 of 7
(6,408 Views)

I prefer the first bullet from this KB.  I prefer it because it's on the palette.  There's a bunch of interesting stuff in the XML string, including the <Choice> items, which are the items in the enumeration.

 

KB 563ETL4S: How Can I Express My Variant as an ASCII String if I Don't Know the Original Data Type?

 

-Steve K

0 Kudos
Message 7 of 7
(6,285 Views)