CA_VariantGet1DArrayBuf
HRESULT CA_VariantGet1DArrayBuf (VARIANT *variant, unsigned int arrayType, void *arrayBuffer, size_t bufferSizeInBytes, size_t *numberOfElements);
Purpose
Converts a 1D safe array in a variant parameter into a C-style array and stores it into a buffer.
On success, CA_VariantGet1DArrayBuf releases the contents of the variant parameter and marks it as empty.
CA_VariantGet1DArrayBuf returns an error if the buffer is not big enough to hold the array.
Example Code
The following code shows you how to use CA_VariantGet1DArrayBuf:
double dblArray[1024];
VARIANT variant;
unsigned numElements;
int index;
/* Call an ActiveX function that returns a safe array in a Variant. */
.
.
.
/* Convert the safe array the variant contains into a C-style array. */
CA_VariantGet1DArrayBuf(&variant, CAVT_DOUBLE, dblArray, sizeof(dblArray), &numElements);
for (index = 0; index < numElements; index++)
printf("%f", dblArray[index]);
Parameters
Input | ||||||||||||||||
Name | Type | Description | ||||||||||||||
arrayType | unsigned int | Data type of the array that CA_VariantGet1DArrayBuf creates from the safe array. arrayType parameter must be the same as the type of the safe array except for the following cases:
arrayType can contain any of the fundamental data types for variants, safe arrays, and properties except CAVT_EMPTY or CAVT_NULL. The CA_VariantGet1DArrayBuf ignores the CAVT_ARRAY modifier. If you do not know the type of the array, you can call CA_VariantGetType and pass its return value as the arrayType. |
||||||||||||||
bufferSizeInBytes | size_t | Number of bytes in the arrayBuffer parameter. | ||||||||||||||
Output | ||||||||||||||||
Name | Type | Description | ||||||||||||||
variant | VARIANT | Pointer to a variant that contains a 1D safe array. CA_VariantGet1DArrayBuf frees the contents of the variant contents and marks it as empty. |
||||||||||||||
arrayBuffer | void * | Buffer to receive the C-style array elements. The type of the array must be the same as arrayType. If the C-style array contains elements of one of the data types in the following table, use the corresponding function to free each element when you no longer need it.
|
||||||||||||||
numberOfElements | size_t | Number of elements CA_VariantGet1DArrayBuf stores in arrayBuffer. You can pass NULL for this parameter. |
Return Value
Name | Type | Description |
status | HRESULT | A value indicating whether an error occurred. Negative error codes indicate function failure. Error codes are defined in CVIversion\include\cviauto.h and <Program Files>\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\winerror.h. The LabWindows/CVI ActiveX Library explicitly returns error codes. Other error codes in winerror.h are generated by ActiveX servers and passed on to you by the LabWindows/CVI ActiveX Library. You can use CA_GetAutomationErrorString to get the description of an error code or CA_DisplayErrorInfo to display the description of the error code. |
Additional Information
Library: ActiveX Library
Include file: cviauto.h
LabWindows/CVI compatibility: LabWindows/CVI 5.0 and later