From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I retrieve VARIANT data from my Activex output using LabWindows/CVI?

I am talking to a piece of equipment using ActiveX and the return type after querying for data is VARIANT. Now I try the command, "CA_VariantHasArray (data);" and it returns a 1. Then I ask for the type and it returns a 0x1070 which according to the documentation is an array of Variants. Now I figured that maybe this array held a bunch of variants that contained double data, but when I call the function, "CA_VariantGet1DArray (data, CAVT_VARIANT, dataArray, &numPts);" I only get a copy of the variant and when I try to perform operations on the new variant I get an error "Variant not initialized"

the code looks like this

AgilentPNA835x_IMeasurementgetData (measObj, NULL, AgilentPNA835xConst_
naCorrectedData,
AgilentPNA835xConst_naDataFormat_LogMag, data);
status=CA_VariantHasArray (data);
type = CA_VariantGetType (data);
status = CA_VariantGet1DArray (data, CAVT_VARIANT, dataArray, &numPts);
type = CA_VariantGetType (dataArray);

I guess I should also say that the numPts variable in the call to "CA_VariantGet1DArray" returns 101 which is what I expect because I am looking for 101 data points from the instrument.

I don't understand how I can get at the data being returned to me.
0 Kudos
Message 1 of 2
(2,780 Views)
Hello

Can you try retriving the data as a array of doubles ( or floats, depending on what you need) and does it return the correct data to you?

Im not sure whether you are getting just a copy of the array directly. Perhaps your data initially is a variant that holds an array, and after CA_VariantGet1DArray, it returns the data as an array of variants, and perhaps that is causing the problem.

Try retrieving the values from your variant another datatype rather than as a variant aand see whether it allows you to do the manipulations with that array.

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(2,780 Views)