Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

Enumerated Types

An enumerated type defines a named set of values.

IEC 61131-3

Section 2.3.3.1

Support

Partial

Syntax

TYPE
    type_name : ( value1, value2, ... ) ;
END_TYPE

Example

TYPE
    TrafficLight : (Red, Yellow, Green);
END_TYPE

PROGRAM main
    VAR
        state : TrafficLight := Red;
    END_VAR

    IF state = Green THEN
        state := Yellow;
    END_IF;
END_PROGRAM

Enumerated values must be unique within the type. Values can optionally include a type qualifier:

TYPE
    Color : (Red, Green, Blue) INT;
END_TYPE

See Also