Attention

IronPLC supports IEC 61131-3 Structured Text excluding I/O mapping.

Function Call

Functions and function blocks are invoked using call syntax that passes arguments and receives results.

IEC 61131-3

Section 3.3.2.2

Support

Partial

Syntax

Function call (expression)

result := function_name ( argument_list ) ;

Function block instance call (statement)

instance_name ( input_assignments ) ;
output_value := instance_name.output_name ;

Description

Functions are called within expressions and return a value. Function blocks are called as statements on a previously declared instance variable; outputs are accessed by qualifying the instance name with the output name.

Positional arguments pass values in the order of the input parameter declarations:

result := MyFunc(10, 20);

Named (formal) arguments explicitly associate values with parameter names using the := notation:

result := MyFunc(x := 10, y := 20);

Positional and named arguments must not be mixed in a single call.

Function block calls use named arguments for inputs. After the call, outputs are read from the instance:

my_timer(IN := start_signal, PT := T#5s);
elapsed := my_timer.ET;
done := my_timer.Q;

Example

See Also