LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can not find CA_Get2DArrayElement in the ActiveX library

HI,
I am trying to access a 2D array (in Labwindows ver 6.0),
this array was a variant that I got from my TestSTand sequence,
the array is declared as double * Array2D;
unsigned int 1Delem;
unsigned int 2Delem;
the problems is how could I access an element of this kind of Array?, for example I wish to make next comparison:
int i;
int j;
if (Array2D[i*1Delem] [j*2Delem] == 50)
else

Just where the comparison is made (==) I receive the error (Type error:Pointer expected),
looking in the documentation I found that CA_Get2DArrayElement could be helpful but it doesn't
in my ActiveX library,

can somebody help?


Many thanks
0 Kudos
Message 1 of 3
(3,164 Views)
Hello EngMax,

Since your 2dArray is defined just as a pointer to a double, you can try to access the element you want by indexing your array like so:

To get array[i][j] where i is the row and j is the column, in psuedocode, you would something like
Array2D[(i * (length of each row) + j)].

Also, the CA_Get2DArrayElement function, as mentioned in function help is a macro.

The function help for VariantGet2DArray mentions how to use this macro:
double * dblArray = NULL;
VARIANT variant;
unsigned numElemsDim1, numElemsDim2;
int index1, index2;
/* Call an ActiveX function that returns a safe array in a Variant. */
.
.
.
/* Convert the safe array the variant contains into a C-style array. */

HRESULT CA_VariantGet2DArray(&variant, CAVT_DOUBLE, &dblArray, &numElemsDim1, &numElemsDim2);

for (index1 = 0; index1 < numElemsDim1; index1++)

for (index2 = 0; index2 < numElemsDim2; index2++)

{
double d;
d = CA_Get2DArrayElement(dblArray, numElemsDim1, numElemsDim2, index1, index2, double);
printf("%f", d);
}

/* Free the allocated array. */
CA_FreeMemory(dblArray);


Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
Message 2 of 3
(3,157 Views)
Hello Wendy,
Many thanks for your help,
I am going to try it in my code,

EngMex
0 Kudos
Message 3 of 3
(3,145 Views)