Attention

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

P2004

Code

P2004

Message

Enumeration is not declared

This error occurs when a type is referenced as an enumeration but is not declared as an enumeration type.

Example

The following code will generate error P2004:

TYPE
    MyStruct : STRUCT
        Field1: BOOL;
    END_STRUCT;
END_TYPE

FUNCTION_BLOCK Example
VAR_INPUT
    Level : MyStruct := CRITICAL;  (* Error: MyStruct is not an enumeration *)
END_VAR
END_FUNCTION_BLOCK

The variable Level is assigned an enumeration value CRITICAL, but MyStruct is declared as a structure, not an enumeration.

To fix this error, use the correct enumeration type:

TYPE
    LogLevel : (CRITICAL, WARNING, INFO, DEBUG) := INFO;
END_TYPE

FUNCTION_BLOCK Example
VAR_INPUT
    Level : LogLevel := CRITICAL;  (* Correct: LogLevel is an enumeration *)
END_VAR
END_FUNCTION_BLOCK