There are several methods to obtain both string indications of all items of an enum, as well as determining only the currently selected item. Use the snippet and method descriptions below to learn a few ways to approach this question.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
Method 1: Property Node with an Enum Control or IndicatorIn case an enum control or indicator exists, create a Property Node for the enum and select the RingText.Text property. This property returns the currently selected item as a string.Method 2: Property Node with an Enum Control or IndicatorThis method is the same as method 1, except that it uses a Reference to define which Control/Indicator to use. You can create a Reference by right-clicking a Control's/Indicator's terminal on the Block Diagram and selecting Create » Reference.Method 3: Property Node with an Enum Control or IndicatorIn case an enum control or indicator exists, create a Property Node for the enum (like in method 1 or 2) and select the Strings property. This property returns an array of strings for all items of the specified enum. In case you want to pick only the currently selected one, use the Index Array function with the enum wired to the index terminal to access the desired string.Please be advised that Property Nodes do not work with constants on the Block diagram. The previously mentioned methods do therefore not work with constants. The following two methods whatsoever work with enum constants as well.Method 4: Format Into String with an Enum Constant, Control, or IndictatorWire the enum to the Format Into String function input, with a format string value of %s wired to the format string input. This function will return the string value associated with the currently selected enum value.In the example above, a constant is used, but this could be replaced with a local variable to the control as this method works with cotrols (or indicators)Method 5: LAVA's OpenG Get Strings from Enum.vi function with an Enum Constant, Control, or IndictatorThis method uses a VI from OpenG LabVIEW Data Library named Get Strings from Enum__ogtk.vi. Wiring an enum converted to variant, it will return all strings as well as the currently selected one. LAVA's OpenG LabVIEW Data Library is available through VI Package Manager (VIPM).(If you do not have OpenG Library, you can use a Diagram Disable Structure to disable the last method but still be able to explore the others.)
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.