Variables
The scope of variables can be local to a program organization unit (POU) or global to a device. Use local variables within one POU only. Use global variables within any POU of the device.
Variable names may have up to 32 characters beginning with a letter or single underscore followed by letters, digits, and single underscore characters. Names cannot be reserved words, defined words, or data types. Names must be unique.
All variables have an attribute and direction. Variables have one of these attributes:
Attribute | Description |
---|---|
Read/Write | Variable with an initial value that reads or writes |
Read | Read-only variable with an initial value |
Variables have one direction.
Direction | Description |
---|---|
Var | Internal variable. The POU updates this variable. |
VarInput | For I/O wiring, a variable connected to an input device. For functions or function blocks, a local input variable. The system refreshes these variables. |
VarOutput | For I/O wiring, a variable connected to an output device. For functions or function blocks, a local output variable. |
VarGlobal | A global variable |
Assign initial values to global variables or local program variables. Default initial values are 0 or FALSE. An initial value is the value of a variable when a target starts its first cycle.
IMPORTANT:
Do not use or assign initial values for local
variables located in the Global Library. The compiler ignores these values.
Provide Feedback