Obtaining Enum Elements in String Format

Updated Jan 12, 2018

Reported In

Software

  • LabVIEW 8.2.1 Full

Issue Details

I have an enumerated data type and I would like to obtain its elements in string format. Can I obtain the string data based on a user’s selection? Is there a LabVIEW function that can accomplish this?

Solution

You can obtain a string indication of an enum type based on user input using one of the two following methods:

Method 1:  Property Node with an Enum Control
If an enum control or indicator exists, create a property node for the enum and select the Strings[] property.  This property returns an array of strings for the specified enum.  Then use the Index Array function with the enum wired to the index terminal to access the desired string.

Method 2:  Format Into String
If there is no enum control or indicator in the VI, wire the enum to the Format Into String function input; with a string value of %s wired to the format string input.  This function returns the string value associated with the input enum value.

The example below (Figure 1) demonstrates how each of these two methods are used: 

Figure 1: Property Node method and Format Into String method.

WAS THIS ARTICLE HELPFUL?

Not Helpful