How can I obtain the type of an OLE variant? Using the "Variant to String" function always returns a type descriptor of "reference". Looking at the control, the "Variant Type" attribute is present. I found a previous thread here, but with no responses.
Since the OLE variant is a "reference", closing and re-opening the a VI will "lose" the data contained within the indicator. Therefore, I cannot post a VI for testing of this.
The type is necessary so I can call the proper "Variant to Data" function. My current work-around is to call the "Variant to Data" for all of the possible types (see image below) until I get an error.
Any help or advice would be appreciated!
I don't know if they'll work for OLE Variant Data, but see if any of the functions in vi.lib\utility\VariantDataType\VariantType.lvlib can get you the information you need. I'd try "Get Type Info.vi." If that fails, you could try converting the variant directly to a string (with variant to data) and then look at that string to see if it tells you anything. I had to do this with a complex type returned by an ActiveX call - all I could get from it was a string that I then had to parse into real data following the matching C structure definition.
I tested various functions with the info shown below:
1. vi.lib\utility\VariantDataType\Get Type Info.vi
Returns "array" for everything
2. Flatten to string returns the same data for everything
The "variant type" attribute is displayed properly in a LabVIEW indicator. There must be a way to access it...
Any other ideas?
The MGI toolkit calls VIs in the vi.lib\Utility\VariantDataType\ directory. I gave every VI a try in the pallete. None of them return the type of data contained in the OLE variant. The majority of them return Error 1. The GetTypeInfo returns "External Data".
The solution to this is to use a Call Library Node to call the LabVIEW manager function MoveBlock().
Configure the first parameter to be an ActiveX Variant, second parameter is an 16 bit integer passed as pointer to value, and the third is a 32 bit integer passed as value.
The function is in this post, with the name Get OLE Variant Type.vi.
I’m on vacation with no access to my computer. But the description earlier should be almost all you need.
Call Library Node: Library Name: LabVIEW (case is important). Calling Convention: C
Function Name: MoveBlock
return value: void
1st Parameter: Active X Variant
2nd Parameter: uint16, passed as Pointer
3rd Parameter: pointer sized integer, passed by value
wire the Variant to the first Parameter and a constant with the value 2 to the third. The second parameter returns a value that matches the VT_ values from MSDN. https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-oaut/3fe7db9f-5803-4dc4-9d14-5425d3f...