The INI
operator is an operator of CODESYS V2.3 Gateway Server. 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 Gateway Server.
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 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

For more information, see: ⮫ “Variable: RETAIN ”, ⮫ “Preserving Data with Retain Variables ”