07-24-2013 07:12 AM - edited 07-24-2013 07:18 AM
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
Solved! Go to Solution.
07-24-2013 07:25 AM
As i understand you want to get the string from the Enum..!! Correct?
07-24-2013 08:51 AM
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
07-24-2013 09:41 AM - edited 07-24-2013 09:42 AM
07-24-2013 09:57 AM
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
07-25-2013 08:04 AM
NI keeps the good stuff burried.
11-11-2013 12:30 PM - edited 11-11-2013 12:32 PM
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