Attribute 'initialize_on_call'

The pragma can be applied to input variables. It causes the input variables of a function block to be initialized each time the function block is called. If an input variable is affected that expects a pointer and this pointer was removed during an Online Change, the variable is initialized with zero.

Syntax: {attribute 'initialize_on_call'}

Insertion location: Always in the first line in the declaration part for the whole function block and additionally in a line above the declaration of the individual input variables

Sample:

If an input expects a pointer and this input is associated with the attribute, this pointer is reinitialized each time the function block is called. This can be used to prevent that a pointer is used that may have become invalid during an online change.

{attribute 'initialize_on_call'}
FUNCTION_BLOCK FB_Test
VAR_INPUT
    {attribute 'initialize_on_call'}
    pSetpoint : POINTER TO LREAL := 0;
END_VAR
VAR_OUTPUT
END_VAR

The pointer should be assigned when the function block is called.

fbTest(pSetpoint := ADR(fSetpoint));