LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Info about Enum TypeDef as Variant using Hidden Gems in vi library

Hi, 

 

I am using LabVIEW 2013 SP1.

 

I need to input different strict type definition enums into a subvi, so I have decided the subvi input to be Variant and to use the Hidden Gems in vi library in order to get details about the typedef and the data selected (enum string selected).

 

I found the Hidden Gems in vi library very useful, see the image attached.

However, I would like to have the path of the strict type control but I get an error, and also, in order to get the enum string I can use the enum U16 'data' and select the corresponding index from the 'EnumNames' array, but... as you can see in the image it seems like the variant "knows" what enum string I have selected, but trying to convert it to anything other than U16 produce an error.

 

Maybe there is someone that know how to solve these inconveniences ?

 

Amitai.

Download All
0 Kudos
Message 1 of 5
(3,783 Views)

What additional info in the TypeDef do you need that you can not get from the Variant?

What is it that you need to do inside the sub VI that you could not do with either the Enum string or it's integer Value

I use some extensive Variant processing in my code and I have never needed to reference back to the TypeDef of an Enum

Get Enum Info.png

If you are running 64 bit you could use a U64 to unflatten the Enum (But would you ever have 1E19 items in your Enum!)

You can unflatten with any interger (U8, U16 U32 U64 I8 I16 I32 I64) and they will all work as long as it is large enough to hold the highest number you are likly to see. A I8 will only work up to 127 items. But who has more than 127 items in their Enum.

Even type cast an Enum to a Float.

 

Even with the TypeDef you will not be able type cast or unflatten a variant back to the original Enum

So you have to work with your Enum as either it's Selected Sting or as an I32 (you could use I16 )

Omar
Message 2 of 5
(3,744 Views)

Hi Omar, 

 

Thanks for your prompt reply, 

 

I want to know if there's a possibility to get the full path of the TypeDef control, for my application reasons.

Just thought the GetTypedefPath.vi would work.

 

Regarding the Enum string, I've mentioned in my post that I know it's possible to get it by selecting the index from the EnumNames array, but after I've noticed that the variant "shows" the input string (see top right corner in the SubVI image of my last post) I thought there might be an elegant way to retrieve it.

Both issues are a matter of convenience and I can work-around them.

 

Thanks

0 Kudos
Message 3 of 5
(3,699 Views)

I don't belive the GetTypePath.vi works.

I thought your problem might be that the variant was passed down to a sub VI and that the Type Path is not passed along to the sub VI.

 

So I tried it on the top level VI and it does not work there also. I tried Ver 2014, 2013 and 2012

 

After looking at what is passed along the wire of a Variant, I do not see any data inside the wire of a Variant that could be the path to the Type Def. So I do not know how it could work?

 

Maybe post to the Hidden Gems Community Group

https://decibel.ni.com/content/groups/hidden-gems-in-vilib

Omar
0 Kudos
Message 4 of 5
(3,678 Views)

Thanks Omar, For you reply.

 

I believe you know this.... but I am adding this here anyway - 

 

When using Property Nodes (Scripting) with a Typedef reference, There is a way to get the Typedef Path, 

I believe the Variant VI was supposed to achieve the same.

 

Capture.PNG

I believe the Enum converted to Variant even when passed to a subVI can have access to this information,
for instance, the GetTypeInfo.vi return the file name *.ctl and the last modified timestamp... (see the SubVI image in the first post) so it looks like "it should also have access" to the path...

 

I will use a designated folder for the enums as a workaround for now.

 

Good night.....

0 Kudos
Message 5 of 5
(3,661 Views)