Global Variables - VAR_GLOBAL¶
Global variables are ordinary variables, constants, external or remanent variables that are recognized within the entire project.
You declare global variables in global variable lists or in the declaration section of programming objects between the keywords VAR_GLOBAL
and END_VAR
.
The system recognizes a global variable when you prepend the variable name with a dot (for example, .iGlobVar1
).
Attention
If a local variable that is declared in a block has the same name as a global variable, then it has precedence within the block.
Attention
For compiler version 3.2.0.0 and later, CODESYS always initializes global variables before the local POU variables.
Example
VAR_GLOBAL
\ iVarGlob1 : INT;
END_VAR
See also