08-23-2011 07:10 AM
Hi Ppl,
I'm reading ActiveX data from an application(TestStand) in LabVIEW. The data I get is of the type ActiveX Variant. When I use variant to data node I'm able to convert the data to the corresponding data type. Howevere in my application the data type varies dynamically and I cannot use the variant to data node.
I will have to flatten it to string. But the flatten to string node does not work with ActiveX variants. It only works with LabVIEW variant types. So is there any way that i could convert ActiveX variant types to LabVIEW variant. I tried the to variant node too. I too does not convert it as expected.
Thanks,
Sathish
Here is how both the variant types differ
Activex variant (boolean):
'': OLE Variant
Variant Type -> VT_BOOLValue -> FALSE
LabVIEW variant(boolean):
'Boolean': boolean (TRUE or FALSE)
FALSE
08-24-2011 04:20 AM
Hi Satish,
ActiveX variants are meaningless when flattened; the data returned is always 16 bytes of zeros. This applies to the Variant to Flattened String function too. What you can do is convert such variants to normal data types and then to strings. But this might not solve your problem as you have mentioned that in your application the data type varies dynamically.
Can you provide me some more information about your application so that I can suggest a work around.
Thanks,
Joe
08-24-2011 04:36 AM
Also pls check if Get Variant Attribute Function can be used to dynamically input data type to the variant to data node.
08-24-2011 04:42 AM
Hey Joe, Thanks for replying. I'm actually storing the control values of a VI in TestStand Properties(locals/file global). TestStand has API's that can be called in LabVIEW to get/set these values. So when I retrieve these values stored in the TestStand properties I actually get them as ActiveX/OLE Variants as I have mentioned. When I set the value as variant(value property in LabVIEW) for basic data types like boolean, numeric, string these work fine. But for Arrays and clusters I actually get the reference to the container. So I'm having to get the indivdual elements of the container as variants and build this individual variants into variant cluster, so that this variant cluster can be set to the control using the value property.
I tried using the OpenG\lvdata\lvdata.llb\Array of VData to VCluster__ogtk.vi that converts array of variant to varinat cluster. But realized it does not work with ActiveX variants as this function internally uses variant to flatten string which doesn not work with ActiveX variants.
Hope this is clear.
11-03-2011 02:10 PM
Hi lordsathish,
Unfortunately, there is no way in LabVIEW to access type data for OLE/ActiveX variant data. However, you can obtain information about the datatype of a TestStand PropertyObject using the ValueType method:
myObject.Type.ValueType
This will return the data type (see the ValueType help entry for more details). you can then use the specific type methods (getValBoolean, etc) to extract data. In the case that you have an array, you can use the ArrayDimensions and ElementType to extract the data from the array. In the case of a container, the contained items will be considered propertyObjects, so you can use the getNumSubProperties and getPropertyObject methods to access the contained items.
Refer to the PropertyObjectType reference help for details on these methods
I hope this clarifies!