Arrays

KiXtart supports arrays with up to 60 dimensions. Arrays allow you to refer to a series of variables by the same name and to use a number (an index) to tell them apart. This helps you create smaller and simpler code in many situations, because you can set up loops that deal efficiently with any number of cases by using the index number. Arrays have both upper and lower bounds, and the elements of the array are contiguous within those bounds. Because KiXtart allocates space for each index number, avoid declaring an array larger than necessary.

 

When declaring an array, follow the array name by the upper bound in square brackets. The upper bound cannot exceed 2,147,483,647.

Arrays can be declared with zero elements:

 

Examples:

 

Dim $Counters[14]       ; explicit declaration

Dim $Sums[20,3]         ; explicit declaration

 

$NewArray = 10,20,30    ; implicit declaration

 

$Array = "A1","B2","C3" ; implicit declaration

 

Dim $MyArray[]

 

The first declaration creates an array with 15 elements, with index numbers running from 0 to 14. The second creates a two dimensional array of 21 by 4 elements. The third and fourth declarations create arrays with 3 elements, with index numbers running from 0 to 2. The fifth declaration creates an array with zero elements.

 

Arrays always have type variant.

 

Note

Unlike regular variables, arrays can not be used inside strings and can not be assigned a value on the commandline.