Notes regarding the Declaration of Retentive \ Variables and Constants

To guarantee the correct initialization or backing up of variables according to the table shown above, the following rules have to be observed when declaring variables.

Declaration of retentive \ internal variables

The variables have to be declared as VAR_RETAIN or VAR_GLOBAL RETAIN.

Example:

(* Declaration in the global variable lists *)

VAR_GLOBAL RETAIN

byVar : BYTE;

wVar : WORD;

rVar : REAL;

END_VAR

(* Declaration in the program *)

VAR RETAIN

byVar1 : BYTE;

END_VAR

Declaration of retentive \ variables in %M area

The variables have to be declared as VAR_RETAIN or VAR_GLOBAL RETAIN.

Note

Note: As of Control Builder version V1.2 and firmware version V1.2.0, a new persistent area is available which can be buffered by a specific setting in the PLC configuration.

(Link to chapter The addressable PERSISTENT area Inputs, Outputs and Flags)

Declaration of constants

Constants are declared as VAR_GLOBAL CONSTANT or VAR_CONSTANT.

Example:

(* Declaration as global constants *)

VAR_GLOBAL CONSTANT

byConst_1 : BYTE := 1;

END_VAR

(* Declaration in the program *)

VAR CONSTANT

byConst_2 : BYTE := 2;

END_VAR

Note

Note: Using the option “Replace constants” available under “Project” => “Options” => “Build”, it is possible to specify whether constants are treated as variables (i.e., writing the variable is possible) or the value is directly entered into the code when building the project.