Attention

IronPLC can only run very simple programs. The steps described are accurate but many language features are not yet supported.

P4001

Code

P4001

Message

Function call mixes named (formal) and positional (non-format) input arguments

This error occurs when a function block invocation mixes named (formal) and positional (non-formal) input arguments.

Example

The following code will generate error P4001:

FUNCTION_BLOCK Callee
VAR_INPUT
    Input1: BOOL;
    Input2: BOOL;
END_VAR
END_FUNCTION_BLOCK

FUNCTION_BLOCK Caller
VAR
    FbInstance : Callee;
END_VAR
FbInstance(Input1 := TRUE, FALSE);  (* Error: Mixed formal and non-formal arguments *)
END_FUNCTION_BLOCK

The function block invocation mixes named input Input1 := TRUE with positional input FALSE, which is not allowed.

To fix this error, use either all named or all positional arguments:

FUNCTION_BLOCK Callee
VAR_INPUT
    Input1: BOOL;
    Input2: BOOL;
END_VAR
END_FUNCTION_BLOCK

FUNCTION_BLOCK Caller
VAR
    FbInstance : Callee;
END_VAR
FbInstance(Input1 := TRUE, Input2 := FALSE);  (* Correct: All named arguments *)
END_FUNCTION_BLOCK