SetArrayDimensions

Arrays
Aptilis 2

SetArrayDimensions(Array[], dim1size, dim2size, ...)

SetArrayDimensions allows you to declare multidimensional arrays. Multidimensional arrays need to be declared and space in memory needs to be reserved for their elements. Aptilis needs to know the size of each dimension in order to calculate where to store a value.
A consequence of this is that you may get errors at run-time, that is in the middle of a program being run. This happens very rarely with Aptilis which is not fussy and tolerates your errors, however an array index out of range will stop a program dead in its tracks.

Return Value:
The total number of elements in the array or 0 if not enough memory was available for the array.

Example:

setArrayDimensions(squares[], 6, 4)

for y = 0 to 3
for x = 0 to 5
squares[x,y] = x * y
end for
end for

for y = 0 to 3
for x = 0 to 5
print(format(" ", 3, 0, squares[x,y])$)
end for
print("\n")
end for
Result:
  0  0  0  0  0  0
0  1  2  3  4  5
0  2  4  6  8 10
0  3  6  9 12 15

See also GetArrayDimensions, ClearArray.