Attention

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

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