Attention
IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.
Variable Declarations¶
Variables are declared in VAR / END_VAR blocks at the beginning of
a program organization unit.
IEC 61131-3 |
Section 2.4.3 |
Support |
Supported |
Syntax¶
VAR
variable_name : type_name ;
variable_name : type_name := initial_value ;
var1, var2, var3 : type_name ;
END_VAR
Multiple variables of the same type can be declared on a single line separated by commas.
Example¶
PROGRAM main
VAR
counter : INT := 0;
limit : INT := 100;
running : BOOL := TRUE;
x, y, z : DINT;
END_VAR
counter := counter + 1;
END_PROGRAM
See Also¶
Initial Values — initialization syntax
Variable Scope — variable scope keywords