Compiler Error C0049

Message

The constant index ‘<index value>’ is not within the range from ‘<start index>’ to ‘<end index>’

Message Cause

An index is specified that is outside the size of the array.

Solution

Only use indexes that are within the size of the array.

Error Example

PROGRAM PLC_PRG
VAR
 arr1 : ARRAY[1..2] OF INT;
END_VAR

arr1[3] := 1;

--> C0049: The constant index '3' is not within the range from '1' to '2'

Error Correction

arr1[2] := 1;