-

Calling Functions and Function Blocks in ST

In ST, a function call basically has the following syntax:

OutVariable := functionName(InVar1, InVar2);

The names of the required input variables are noted in parentheses after the function name. The function's return value (result) has to be assigned to an output variable.

A function block call in ST basically has the following syntax:

instance(invar1:=1, invar2:=2);
a:= instance.outvar1;

Alternative syntax:
instance(invar1 := 1, invar2:=2, outvar1 => a);

In this example, an FB with the instance name 'instance' is called with its input parameters 'invar1' and 'invar2' (each with assigned value). The FB returns a result in form of the output variable 'outvar1'. In our sample call, the result value is written to the variable 'a'.

Note
EN/ENO allows an optional conditional execution of functions and function blocks according to the IEC 61131-3 standard. EN is an enable input, ENO an enable output formal parameter. Refer to the help topic "Execution Control: EN/ENO" for details.