Variable: VAR_GLOBAL Permalink

NOTICE

NOTICE
NOTICE
NOTICE

NOTICE

NOTICE

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.

NOTICE

NOTICE
NOTICE
NOTICE

NOTICE

NOTICE

For compiler version 3.2.0.0 and higher, CODESYS always initializes global variables before the local POU variables.

Global variables are variables, constants, external or remanent variables which are recognized within the entire project. You declare global variables in global variable lists or in the declaration part of programming objects between the keywords ‎VAR_GLOBAL‎ and ‎END_VAR‎.

Example

VAR_GLOBAL
    g_iVar1 : INT;
END_VAR

The system recognizes a global variable when you prepend the variable name with a dot (example: ‎.g_iVar1‎).