Attention

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

P4008

Code

P4008

Message

Variable is constant but does not define value

This error occurs when a variable is declared as constant but does not define an initial value.

Example

The following code will generate error P4008:

VAR_GLOBAL CONSTANT
    ResetCounterValue : INT;  (* Error: CONSTANT variable must have initializer *)
END_VAR

The variable ResetCounterValue is declared as CONSTANT but does not have an initial value assigned.

To fix this error, provide an initial value for the constant variable:

VAR_GLOBAL CONSTANT
    ResetCounterValue : INT := 17;  (* Correct: CONSTANT variable has initializer *)
END_VAR