Attention

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

P0004

Code

P0005

Message

Element is not permitted at this compiler state

This error occurs when an element appears in a context where it is not permitted according to the current compiler state or parsing context.

Example

This error typically occurs when language elements are used in inappropriate contexts, such as:

  1. Using statements outside of executable sections

  2. Declaring variables in inappropriate sections

  3. Using keywords in wrong contexts

TYPE
    DataStruct : STRUCT
        Field1 : BOOL;
        SomeVariable := SomeVariable + 1;  (* Error: Statement not allowed in struct *)
    END_STRUCT;
END_TYPE

The assignment statement SomeVariable := SomeVariable + 1 is not permitted inside a structure declaration.

To fix this error, ensure elements are used in their appropriate contexts:

TYPE
    DataStruct : STRUCT
        Field1 : BOOL;
        Field2 : INT;  (* Correct: Only declarations in struct *)
    END_STRUCT;
END_TYPE