Attention

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

Initial Values

Variables can be assigned initial values in their declaration using the := operator.

IEC 61131-3

Section 2.4.3

Support

Supported

Syntax

variable_name : type_name := initial_value ;

The initial value must be a constant expression compatible with the variable’s type.

Example

PROGRAM main
    VAR
        counter : INT := 0;
        name : STRING := 'default';
        active : BOOL := TRUE;
        delay : TIME := T#100ms;
    END_VAR

    counter := counter + 1;
END_PROGRAM

If no initial value is specified, the variable is initialized to the default value of its type (typically zero or empty).

See Also