Call a Sub-Program

A sub-program is called by another program.

  • Unlike function blocks, local variables of a sub-program are not instantiated and you do not need to declare instances.
  • A call to a sub-program processes the block algorithm using the specified input parameters.
  • Output parameters can then be accessed.

FBD and FFLD Languages

To call a sub-program in FBD or FFLD languages, insert the block in the diagram and connect its inputs and outputs.

IL Language Example

Not available.

ST Language Example

To call a sub-program in ST, you must specify its name, followed by the input parameters written between parentheses and separated by comas.

To have access to an output parameter, use the name of the sub-program followed by a dot . and the name of the parameter:

MySubProg (i1, i2); (* calls the sub-program *)
Res1 := MySubProg.Q1;
Res2 := MySubProg.Q2;

Alternatively, if a sub-program has one and only one output parameter, it can be called as a function in ST language:

Res := MySubProg (i1, i2);