Attribute call_after_init

Overview

Use the pragma {attribute call_after_init} to define a method that is called implicitly after the initialization of a function block instance. For performance reasons, attach the attribute both to the function block itself and to the instance method to be called. The method has to be called after FB_Init and after having applied the variable values of an initialization expression in the instance declaration.

NOTE: Compile errors will be detected if VAR_INPUT declarations are used in methods that contain this attribute. The reason is that the input variables are unknown when the method is called implicitly during online change.

Syntax

{attribute 'call_after_init'}

Example

With the following definition:

{attribute 'call_after_init'}
FUNCTION_BLOCK FB
... <functionblock definition>
{attribute 'call_after_init'}
METHOD FB_AfterInit
... <method definition>

... declaration like the following:

inst : FB := (in1 := 99);

... will result in the following order of code processing:

inst.FB_Init();
inst.in1 := 99;
inst.FB_AfterInit();

So, in FB_Afterinit, you can react on the user-defined initialization.