Very simple test
**New Empty Gig ** Current Rackspace Script Editor
Initialization
var
a : Integer
MyArray : Integer Array
a = 0
While a < 256 do
MyArray <-- a
a = a + 1
End
Print(MyArray[255])
End
Compile
Rackspace (Script Entity: Rackspace) - Array index out of bounds: index (zero-based) = 255: Current array length = 255 Error near line 12 in file: Main
The error message is very clear. With 255 values in your array, with an array starting at index 0, the last element of the array is MyArray[254] not MyArray[255]. The index 255 is out of bounds.
Yes that works, but unfortunately I need to use a dynamic array as I want to process the results from the GetGPPresetList function, and I don’t know how many entries it will return in advance (but I know it’s limited to 256).
Unfortunately the problem persists when using AppendInteger
Initialization
var
a : Integer
MyArray : Integer Array
a = 0
While a < 256 do
AppendInteger(MyArray, a)
a = a + 1
End
Print(MyArray[255])
End
Rackspace (Script Entity: Rackspace) - Warning in “Main”: Line 9, Col 9: (Script: Rackspace (Script Entity: Rackspace) - ) Function AppendInteger is deprecated: Use ← operator instead
Rackspace (Script Entity: Rackspace) - Array index out of bounds: index (zero-based) = 255: Current array length = 255
Error near line 12 in file: Main