Attention

IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include arrays and structures. Try it out in the IronPLC Playground.

Subrange Types

A subrange type restricts an integer type to a specified range of values.

IEC 61131-3

Section 2.3.3.1

Support

Partial

Syntax

TYPE
    type_name : base_type ( lower_bound .. upper_bound ) ;
END_TYPE

The base type must be an integer type (SINT, INT, DINT, LINT, USINT, UINT, UDINT, or ULINT).

Example

TYPE
    Percent : INT (0 .. 100);
    Byte_Range : USINT (0 .. 255);
END_TYPE

PROGRAM main
    VAR
        level : Percent := 50;
    END_VAR

    level := level + 10;
END_PROGRAM

See Also