Retrieving Attributes from Variant Data

Complete the following steps to retrieve a specific attribute from variant data.

  1. Add the Get Variant Attribute function to the block diagram.

     Add  Find
  2. Wire variant data to the variant input of the Get Variant Attribute function.
  3. Wire the name of the attribute to the name input of the Get Variant Attribute function.
  4. Wire the default value input of the Get Variant Attribute function. What you wire to the default value input determines the type of indicator that is created when you wire the value output.
  5. Right-click the found output of the Get Variant Attribute function and select Create»Indicator from the shortcut menu.
  6. Right-click the value output of the Get Variant Attribute function and select Create»Indicator from the shortcut menu to retrieve the value associated with the attribute.
  7. Run the VI.

If found is TRUE, the value indicator displays the value of the attribute. If found is FALSE, the value indicator displays the value you wired to the default value input.

Complete the following steps to retrieve all the attribute names from variant data.

  1. Add the Get Variant Attribute function to the block diagram.

     Add  Find
  2. Wire variant data to the variant input of the Get Variant Attribute function.
  3. Leave the name input and the default value input of the Get Variant Attribute function unwired.
  4. Right-click the names output and select Create»Indicator from the shortcut menu.
  5. Right-click the values output of the Get Variant Attribute function and select Create»Indicator from the shortcut menu to retrieve the values associated with each attribute.
  6. Run the VI.

The names of the attributes appear in the front panel names array indicator. The associated values appear in the values array indicator as a list of variants, which you then can convert for use in VIs and functions.