Enumerated type

From LabVIEW Wiki
Jump to: navigation, search

Located under the Ring & Enum palette, a LabVIEW enumerated type is used to associate a sequential numerical value to a programmer defined string

Enum Palette Location LV 7.1 and below.png

Potential Uses

Enum's can be used with a case selector to provide the programmer an easy way to select a case based on a constant name instead of a number or a string.

Enum connected to case structure.png

Typedef'd Enum's are often used in State Machines to provide the programmer an easy way to select new cases without having to worry about spelling mistakes.

Recommendations

Enums are most commonly used to define a fixed list of cases. If the enum will be used as an input or output on the connector pane of a VI, it should be defined as a typedef. Any changes to the typedef can be automatically propagated to controls, indicators and constants created from the vi's connector pane.

Shortcomings

LabVIEW enumerated types do not allow for non-sequential values, or what might be known as sparse enums. A Ring Constant or Ring Control can be used for this purpose, though the data type will just be a regular integer.

Enum properties page.png

External Links