Arrays

[ Back ]

Arrays can be of any size, dimension and type. You create an array by assigning values to it or by naming it:

an_integer_array[] = [1, 2, 3, 4, 5]
a_float_array[3]
a_float_array[0] = 1.0
a_float_array[1] = 2.5
a_float_array[2] = 5.0
a_2d_string_array$[][] = [["an", "array"], ["of", "strings"]]
another_integer_array[] = an_integer_array
an_empty_3d_float_array[][][]

Arrays may change size, but not number of dimensions, during program execution:

an_integer_array[5]
an_integer_array[] = [1, 2, 4, 5, 6, 7, 8]
another_integer_array[] = an_integer_array
an_integer_array[]

, where the last line clears an_integer_array.

You reach elements by indexing them, starting at 0:

an_integer_array[] = [57, 31, 42]
a = an_integer_array[0]
b = an_integer_array[1]
c = an_integer_array[2]

Sub routines

function sizeof(array)
function sizeof(array, dimension)

function sizeof(array)

Return the number of elements in an array. Ex:

an_array[4]
s = sizeof(array)

, sets s to 4.

function sizeof(array, dimension)

Return the size of a specifik dimension (starting at 0) in an array. Ex:

an_array$[4][3][5]
s = sizeof(array, 1)

, sets s to 3.

[ Back ]