LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the type of a variant...

I'm trying to programatically read the "VersionInfoFileVersionBuild" tag's value associated with a Build Specification.  This is the fourth number in the overall version number. i.e if the version number is "1.4.3.7", the VersionInfoFileVersionBuild is 7.
 
I tried using the "Get Tag" method, with this tag, but the value is returned as a variant.  I've tried converting this variant to data and I keep getting the following error: "LabVIEW:  The data type of the variant is not compatible with the data type wired to the type input."
 
I've tried every numeric type and even strings and the same error keeps coming up.  Can someone tell me what IS the type of the value associated with the "VersionInfoFileVersionBuild", or how do I find it?
0 Kudos
Message 1 of 5
(3,417 Views)
I used the 'Variant to Flattened String' function to take a peek at the 'type string' output. With the help link for that function, it wasn't too hard to figure out that the data type of the data was a signed 32-bit integer. (Check out the information for 'Type Descriptors'.)

So, I just wired up a signed 32-bit integer constant to the 'Variant to Data' function's "type" input and it worked fine.

Hope this helps.
intvsteve
LabVIEW R&D
0 Kudos
Message 2 of 5
(3,408 Views)

Hey intvsteve,

Thanks for trying to help.  I had already tried using I32 as the type input for the "Variant to Data.vi" and it had not worked.  I have even tried flattening the variant to a string and scanning the string.  None of it has worked.  For whatever reason, I'm getting a '4' back for the first element in my "Type String" array which indicates the type is a 64-bit integer.  But that's not working for me either.  I wonder if the problem has to do with this note in the Help for the Type Descriptors:

"Note  The format in which LabVIEW stores type descriptors changed in LabVIEW 8.0. LabVIEW 7.x stores type descriptors in 16-bit flat representation. LabVIEW 8.0 stores type descriptors in 32-bit flat representation. The following information applies if you use the Convert 7.x Data mode of the Flatten to String function.Note  The format in which LabVIEW stores type descriptors changed in LabVIEW 8.0. LabVIEW 7.x stores type descriptors in 16-bit flat representation. LabVIEW 8.0 stores type descriptors in 32-bit flat representation. The following information applies if you use the Convert 7.x Data mode of the Flatten to String function."

I'm using LabVIEW 8.0.  Any other thoughts?

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

Hey intvsteve,

I had made a mistake!  I found it and it works.  Thanks again for your help!

0 Kudos
Message 4 of 5
(3,382 Views)
In LV8.0 and higher, there is a set of routines in vi.lib to help you deal with this sort of issue.  Since they are not on the palette, backwards compatibility is not guaranteed for future versions.  Find them at

<vi.lib>\Utility\VariantDataType
0 Kudos
Message 5 of 5
(3,366 Views)