Attention

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

P4011

Code

P4011

Message

Definition name is duplicated

This error occurs when there are duplicate definition names in the same scope, such as having two functions, function blocks, or programs with the same name.

Example

The following code will generate error P4011:

FUNCTION DuplicateName : BOOL
VAR_INPUT
    InputParam : BOOL;
END_VAR
DuplicateName := InputParam;
END_FUNCTION

FUNCTION DuplicateName : INT  (* Error: Duplicate definition name *)
VAR_INPUT
    InputValue : INT;
END_VAR
DuplicateName := InputValue;
END_FUNCTION

The code defines two functions with the same name DuplicateName, which is not allowed.

To fix this error, ensure all definition names are unique:

FUNCTION FirstFunction : BOOL
VAR_INPUT
    InputParam : BOOL;
END_VAR
FirstFunction := InputParam;
END_FUNCTION

FUNCTION SecondFunction : INT  (* Different name *)
VAR_INPUT
    InputValue : INT;
END_VAR
SecondFunction := InputValue;
END_FUNCTION