Admin Production ni-theme
Current Publication

Meta Data Types

LabWindows/CVI

Meta Data Types

The meta data types are useful for parameters through which users can pass arguments of more than one data type. The meta data types are Numeric Array, Any Array, Any Type, and Var Args. Each of these data types defines a set of multiple allowable data types. When the user executes the Declare Variable command on a control defined with a meta data type, the user can select from a list of the allowable data types.

Numeric Array

Numeric Array specifies a parameter that can be any of the intrinsic C numeric array data types. You must define the parameter as void * in the function prototype. An example of a Numeric Array data type is in the PlotX function of the User Interface Library. The PlotX function plots the values of any intrinsic C numeric array data type to a graph control on a user interface panel. On the function panel, the X Array control is of type Numeric Array. X Array is defined as void * in the following function prototype:

int PlotX (int panel, int control, void *xArray, int numPoints, int xDType, int plotStyle, int pointStyle, int lineStyle, int pointFreq, int color);

Any Array

Any Array specifies a parameter that can be any of the intrinsic C or user-defined array data types. You must define the parameter as void * in the function prototype. An example of an Any Array data type is in the memcpy function of the ANSI C Library. This function copies a specified number of bytes to a target buffer of any type from a source buffer. In the function panel, the first parameter is Target Buffer, which is of type Any Array. Target Buffer is defined as void * in the following function prototype:

void *memcpy(void *, const void *, size_t);

Any Type

Any Type specifies a parameter that can be any of the intrinsic C or user-defined data types. If the parameter is an output parameter, you must define it as void * in the function prototype. If the parameter is an input parameter, you must define it as "..." in the function prototype, and it must be the last parameter in the function. The Value output parameter of the GetCtrlAttribute function in the User Interface Library is an example of the Any Type data type. The function obtains the value of a particular attribute for a particular user interface control. Different attributes have different data types. Users pass the attribute value parameter by reference, and it is therefore a pointer. Consequently, the attribute value parameter is of type Any Type and is defined as void * in the following function prototype:

int GetCtrlAttribute(int panel, int control, int attribute, void *value);

The Value parameter of the SetCtrlAttribute function also applies to attributes of different data types, but it is an input rather than an output parameter. Users pass this parameter by value rather than by reference, and thus it can have different sizes. For example, it might be an int or a double. Consequently, the attribute value parameter is of type Any Type and is defined as "..." in the following function prototype:

int SetCtrlAttribute (int panel, int control, int attribute, ...);

Var Args

Var Args specifies a variable number of parameters that can be any of the intrinsic C or user-defined data types. You must define the parameters as "..." in the function prototype. The printf and scanf functions in the ANSI C Library have examples of the Var Args data type. Following the format string parameter in each function, you can specify one or more parameters of different data types to match the type specifiers in the format string. In printf, the parameters are passed by value. In scanf, they are passed by reference and thus are really pointers. For both functions, one Var Arg function panel control is used, and "..." appears in the following function prototypes:

int printf (const char *, ...);
int scanf (const char *, ...);