Array

<< Click to Display Table of Contents >>

Navigation:  Reference >

Array

It is possible to have arrays of types (although currently you cannot have an array of arrays). Arrays currently have a maximum length of 256. Array indexing is zero-based.

var mySmallArray : integer[32]

 
This creates an array that can contain 32 values. Attempts to reference the array outside the defined range will be trapped by the runtime system and the script terminated. While this adds a little cost, we feel that array range errors are sufficiently common that it's worth the cost. In the future, we may add an option to disable range checking.

You can pass arrays as dynamic parameters to functions and the system function size will return the current size of the array parameter.

Function IntSum(someArray : integer array) returns integer

   var s : integer // Track the sum

   index : integer

 

   for i = 0; i < size(someArray); i = i + 1 do

      s = s + someArray[i]

   end

   

   result = s // Return the result

End