Hi Swapna,
It looks like the VARIANT array part is working fine... I've modified your code slightly to initialize the array and to display the values of the resulting array.
Does this not work for you?
HRESULT status;
CAObjHandle handleArray[6];
VARIANT variantValues[6];
int i;
LPSAFEARRAY variantSafeArray = NULL;
VARIANT * variantValuesRead = NULL;
unsigned int noElements2;
for (i=0; i<6; i++)
status = CA_VariantSetLong(&variantValues[i], i);
status = CA_Array1DToSafeArray (variantValues, CAVT_VARIANT, 6, &variantSafeArray);
status = CA_SafeArrayTo1DArray (&variantSafeArray , CAVT_VARIANT, &variantValuesRead, &noElements2);
for (i = 0; i
{
status = CA_VariantGetLong (&variantValuesRead[i], &myCurrentValue);
printf("Value %d: %d\n", i, myCurrentValue);
}
getchar();
return;
One thing I wanted to mention is the watch window. If you add variantValuesRead to the watch window, by default the CVI engine will only display the first address of the array. This is because of the user protection code for the ActiveX library. The information displayed in the variables window is based on user protection information. This is actually expected behavior since VARIANT is not a C compiler type and so the array length estimation is now shown correctly in the variables and watch windows.
However, you can tell the IDE this by selecting Options >> Estimate Number of Elements and choosing 6. You must click on the variable first before selecting that menu item.
Hope this helps!
Jervin Justin
NI TestStand Product Manager