LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert safearray to lpsafearray?

Hello! Im working with Version 7.1.0.
Does anybody how convert the datatype (pointer of) SAFEARRAY in LPSAFEARRAY???

My ActiveX-Control provides me an SAFEARRAY in the this function:
static SAFEARRAY *SampleArray; double * datapoints=NULL; ........
hResult = AXFifo4Prj__AXFifo4CaptureChBFifo (axfifo4Handle, &err, &numSamples, &SampleArray, &twosComplement, &vBool ); //&*SampleArray

CA_SafeArrayTo1DArray (&*SampleArray, CAVT_DOUBLE,&datapoints,&numSamples);
needs an LPSAFARRAY, so the pointer is already included.

The CA_SafeArrayTo1DArray code line produces this error message:
49, 49 Type error in argument 1 to `CA_SafeArrayTo1DArray'; found 'pointer to SAFEARRAY' expected 'pointer to LPSAFEARRAY'.

Thanks for every help!
0 Kudos
Message 1 of 4
(4,983 Views)
Try this

static LPSAFEARRAY SampleArray;

hResult = AXFifo4Prj__AXFifo4CaptureChBFifo (axfifo4Handle, &err, &numSamples, SampleArray, &twosComplement, &vBool ); //&*SampleArray

...
...

CA_SafeArrayTo1DArray (&SampleArray, CAVT_DOUBLE,&datapoints,&numSamples);

Note : The above safe array function has been superceded by CA_SafeArrayTo1DArrayEx(). And remember to use CA_FreeMemory() to free the C array that is returned.

Hope this helps
Bilal Durrani
NI
0 Kudos
Message 2 of 4
(4,969 Views)
How about if we need to do the reverse i.e. convert from lpsafearray to safearray?

Does similar type casting work?

thanks.
0 Kudos
Message 3 of 4
(4,942 Views)
an lpsafearray is just a pointer to a safearray. you can dereference the lpsafearray to get the safearray.

Just make sure you keep track of allocation and deallocation of the safearray.
Bilal Durrani
NI
0 Kudos
Message 4 of 4
(4,930 Views)