Admin Production ni-theme
Current Publication

CA_VariantSet1DArray

LabWindows/CVI

CA_VariantSet1DArray

HRESULT CA_VariantSet1DArray (VARIANT *variant, unsigned int arrayType, size_t numberOfElements, const void *array);

Purpose

Creates a safe array from a 1D array and stores the safe array in a variant.

Note   Use CA_VariantClear to free the safe array stored in variant.

Parameters

Input
Name Type Description
arrayType unsigned int Data type of array.

arrayType can contain any of the fundamental data types for variants, safe arrays, and properties except CAVT_EMPTY, CAVT_NULL, and CAVT_OBJHANDLE.
numberOfElements size_t Number of elements in array.

An error is returned if you pass a value greater than UINT_MAX.
array const void * 1D array that CA_VariantSet1DArray converts to a safe array.

array can contain any one of the following data types: long, short, float, double, VBOOL, char* (NULL terminated string), unsigned char, BSTR, DATE, CURRENCY, LPUNKNOWN, LPDISPATCH, SCODE, and VARIANT.

Note    CA_VariantSet1DArray does not make copies of BSTR, VARIANT, LPUNKNOWN, or LPDISPATCH elements. CA_VariantSet1DArray copies the pointers into the created safe array. When you call CA_VariantClear, which frees the safe array and all its contents, the BSTR, VARIANT, LPUNKNOWN, or LPDISPATCH elements of the input array parameter become invalid.
Output
Name Type Description
variant VARIANT Variant to which CA_VariantSet1DArray assigns the safe array.

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

Examples

Refer to the following examples that use the CA_VariantSet1DArray function:

  • userint\activex\3DGraphColorMap.cws

    Open example
  • userint\activex\3DGraphContours.cws

    Open example