Admin Production ni-theme
Current Publication

Interacting with Variant and Safe Array Data Types

LabWindows/CVI

Interacting with Variant and Safe Array Data Types

The VARIANT data type is a structure that can hold a value of any valid ActiveX data type. Refer to the Fundamental Data Types for Variants, Safe Arrays, and Properties table and to the Data Type Modifiers for Variants, Safe Arrays, and Properties table for valid ActiveX data types. ActiveX server functions declare a parameter as a VARIANT when the parameter can take a value of more than one data type. This help uses the term variant to refer to parameters or variables declared with the VARIANT data type. The ActiveX Library provides functions to help you pass values as variant input parameters and retrieve values from variant output parameters.

The SAFEARRAY data type is a structure that holds an array of data, the number of dimensions in the array, and the size of each dimension. ActiveX server functions use the SAFEARRAY data type to pass arrays. This document uses the term safe array to refer to parameters or variables declared with the SAFEARRAY data type. The ActiveX Library provides functions to convert between C-style arrays and safe arrays stored inside variants, functions to obtain the number of dimensions in a safe array, and functions to obtain the size of each dimension.

You can declare a variant structure as a local or global variable, but safe arrays are always dynamically allocated. Consequently, you must always reference safe arrays using pointers. Use the LPSAFEARRAY typedef to declare a pointer to a safe array. Microsoft adds LP at the beginning of data type names to indicate a pointer to a data type. Thus, LPSAFEARRAY signifies a pointer to a SAFEARRAY.