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.
V4005¶
- Code
V4005
- Message
Array index out of bounds
The program attempted to access an array element with an index that is outside the valid range. The index must be between the declared lower and upper bounds of the array.
Example¶
The following code will generate error V4005:
PROGRAM Main
VAR
values : ARRAY[1..5] OF INT;
result : INT;
END_VAR
result := values[6]; (* Error: index 6 is out of bounds for ARRAY[1..5] *)
END_PROGRAM
The array values has valid indices 1 through 5, but index 6 is outside
that range.
To fix this error, ensure the index is within the declared bounds of the array: