Attention
These docs are a bit ambitious. The steps described are accurate but IronPLC cannot yet run programs.
P0015¶
- Code
- P0015 
- Message
- Variable not defined before used 
This error occurs when a variable is referenced but not declared in the current scope.
Example¶
The following code will generate error P0015:
FUNCTION_BLOCK LOGGER
VAR
    TRIG0 : BOOL;
END_VAR
TRIG := TRIG0;  (* Error: TRIG is not declared *)
END_FUNCTION_BLOCK
The variable TRIG is used in the assignment but is not declared in the VAR section of the function block.
To fix this error, declare the variable in the appropriate variable section:
FUNCTION_BLOCK LOGGER
VAR
    TRIG : BOOL;   (* Declare the variable *)
    TRIG0 : BOOL;
END_VAR
TRIG := TRIG0;  (* Correct: TRIG is now declared *)
END_FUNCTION_BLOCK