Attention
IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include arrays and structures. Try it out in the IronPLC Playground.
P2028¶
- Code
P2028
- Message
REF() operand must be a simple variable
This error occurs when the REF() operator is applied to something other than a simple variable. The REF() operator creates a reference (pointer) to a variable, and the operand must be a named variable.
Example¶
The following code will generate error P2028:
PROGRAM Main
VAR
x : REF_TO INT;
END_VAR
x := REF(42); (* Error: REF() operand must be a variable, not a literal *)
END_PROGRAM
To fix this error, use a named variable as the operand:
PROGRAM Main
VAR
counter : INT;
x : REF_TO INT;
END_VAR
x := REF(counter); (* Correct: counter is a simple variable *)
END_PROGRAM