Variant data type

From LabVIEW Wiki
(Redirected from Variant)
Jump to: navigation, search

A Variant is a data type that any other LabVIEW data type will coerce to and that can contain any other LabVIEW data type inside it. In order to do useful things with variants, you will need to inspect the type descriptor to determine the actual data type flowing through the variant at run-time. When working with variants, it is recommended to use tools such as the OpenG LabVIEW Data (Variant) Tools Library.

Variants work really well for sending messages that may contain different types of data accompanying the message. This can be done as a cluster containing either a string or an enumerated type as the first element and a variant as the second. Another method is to convert the message (string or enum) to a variant and then add the data into the attributes.

Variant attributes are data elements that are stored and retrieved by name. This can be very beneficial if your data is best accessed by a name.

NI support for variants

In LabVIEW 8.0 NI has improved the performance of variants dramatically. Together with the improved performance a limited API was released in the vi.lib under <vi.lib>\Utility\VariantDataType. An palette file for this API is downloadable File:NI Variant Palette.zip.

The NI API is limited since it only access the variant data-type and not the data inside the variant. Any editing of the datatype results in an empty variant.

External links