Global Variables - VAR_GLOBAL

Global variables are "normal" variables, constants, or retentive variables that are known throughout the project.

Global variables are declared in global variable lists between the keywords VAR_GLOBAL and END_VAR.

The system detects a global variable if the variable name is prefixed with a dot, for example ".nGlobVar1“.

Global Variables - VAR_GLOBAL 1:

A variable declared locally in a function block, which has the same name as a global variable, has priority within the function block.

Global Variables - VAR_GLOBAL 2:

Global variables are always initialized before the local variables of POUs.

Example:

VAR_GLOBAL
    nVarGlob1 : INT; 
END_VAR

See also: