Jump to content

How to get 'Info' data from a variant


Recommended Posts

How can I get the 'Info' data contained in a variant? I want to get the variable type of the elements in an array. For example, I used the GetArrayInfo VI to get the following info from my array and want to extract the U32 info contained in it.

post-2786-125734159733_thumb.jpg

George

If you use the "variant to flattened string" function, it has a type output array.

Link to comment

For simple types, you can use <LV>\vi.lib\Utility\VariantDataType\GetTypeInfo.vi. There are other useful bits in that folder, too.

I wish they'd put some of these on the default palette... it always takes me a few minutes to remember where they are!

Joe Z.

Edit: "On closer inspection...". Of course, ShaunR's answer is more correct for your question.

Sorry, I'm not used to this side of the AM/PM :)

Edited by jzoller
Link to comment

For simple types, you can use <LV>\vi.lib\Utility\VariantDataType\GetTypeInfo.vi. There are other useful bits in that folder, too.

Joe Z.

Edit: "On closer inspection...". Of course, ShaunR's answer is more correct for your question.

Yeah, I think ShaunR got it. The GetTypeInfo VI doesn't return the Info data within the variant that I wanted. It returns the overall type of data within the variant - like Enum or Array.

George

Link to comment
Yeah, I think ShaunR got it. The GetTypeInfo VI doesn't return the Info data within the variant that I wanted. It returns the overall type of data within the variant - like Enum or Array.
All of the info in the variant's type should be accessible through the VIs in the same folder as GetTypeInfo. In fact, GetTypeInfo should have returned "int32" to you. Isn't that the info you wanted? If there's some aspect of the variant that you can't get from the VIs in that directory, I'd be surprised, since those are the type handling VIs that we in R&D created to manipulate all the types from G. They should be as rich as anything I can get access to in the C++ code.
Link to comment

All of the info in the variant's type should be accessible through the VIs in the same folder as GetTypeInfo. In fact, GetTypeInfo should have returned "int32" to you. Isn't that the info you wanted? If there's some aspect of the variant that you can't get from the VIs in that directory, I'd be surprised, since those are the type handling VIs that we in R&D created to manipulate all the types from G. They should be as rich as anything I can get access to in the C++ code.

I ended up using the GetArrayInfo VI to get the data for one element of the array. From there I got type descriptor string from the Variant to Flattened String. I fed the type descriptor to the Get Type Code from I16 Array VI which gave me the element type that I wanted.

George

Link to comment

I ended up using the GetArrayInfo VI to get the data for one element of the array. From there I got type descriptor string from the Variant to Flattened String. I fed the type descriptor to the Get Type Code from I16 Array VI which gave me the element type that I wanted.

Post a block diagram, please. There has to be a simpler way to do this.
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.