Skip to main content

Operator: INI

Tip

The INI operator is an operator of CoDeSys V2.3. This operator is replaced by the FB_Init method as of CODESYS V3. However, you can still use this operator in projects that are imported from CoDeSys V2.3.

Syntax

<boolean variable name> := INI ( <FB instance name> , <boolean value> );
// <boolean value> : TRUE | FALSE

With the INI operator, you can trigger the initialization of retain variables of a function block instance used in a POU.

If the second parameter of the operator is TRUE, then CODESYS initializes all retain variables which are defined in the function block <FB instance name> and then returns TRUE.

Example 165. Example in ST

fbinst is the instance of the function block fb1, where the retain variable retvar is defined.

VAR
    fbinst : fb1;
    b : BOOL;
END_VAR

b := INI(fbinst, TRUE);
ivar := fbinst.retvar; (* => retvar is initialized *)

Example in FUP

_cds_img_ini_operator.png


For more information, see: RETAIN, Preserving Data with Retain Variables