Attribute 'init_on_onlchange'

The pragma causes the variable, to which the pragma is applied, to be initialized with each online change.

Attribute 'init_on_onlchange' 1:

Fast online change

For small changes (e.g. in the implementation section, with no shifting of variables required), a "fast online change" is performed. In this case, only the modified function block is compiled and reloaded. In particular, no initialization code is generated in this case. This also means that no code for initializing variables with the attribute 'init_on_onlchange' is generated. Usually this will not have any effect, since the attribute tends to be used to initialize variables with addresses, but a variable cannot change its address during a fast online change.

To ensure the init_on_onlchange attribute is applied to the entire application code, deactivate fast online change for the PLC project using the no_fast_online_change compiler definition. To this end, insert the definition in the Compile category of the PLC project properties.

Attribute 'init_on_onlchange' 2:

The attribute 'init_on_onlchange' has no effect for individual FB variables

The Attribute 'init_on_onlchange' only applies to global variables, program variables and local static variables of function blocks.

To reinitialize a function block during an online change, the function block instance must be declared with the attribute. The attribute is not evaluated for a single variable in a function block.

Syntax: {attribute 'init_on_onlchange' }

Insertion location: Line above the declaration line of a variable