When you are using arrays and you attempt to assign a value to one element of an array that has not yet been created, you get the painfully common "Indice out of range" error.
A good way to fight that error is to retrieve the size of the array before the assignment and create on the fly the element needed. For example, the following code assigns a serie of values through a loop.
If the array does not have the 25 first elements already created, you will run into the "Indice out of range error."
The same code when modified as follows will create the elements when needed and will not encounter that error.
$PreviousSize:=Size of array($MyArray)