Arrays

Arrays are linked DataTypes of the same Type. Numeric Variables, String variables and Structures can be dimensioned as one dimensional arrays. Static means that the number of elements is declared explicitly. You may add a Structure to define sub elements. Add the number of elements in brackets „()“ to the Variable to define an array. The number of elements and the first index is zero based. The first element of an array has index „0“.

You can read the number of elements in the array with Ubound:

dim i,a(63) as byte
for i=0 to a().Ubound
  [..]
next

Array elements and all other variables in work memory are 0, nil or empty by default. Arrays and variables in eeprom memory are not initialized.

Example for dimensioning in memory
dim a(99) as byte   ' Byte-Array with 100 elements
dim s(2) as string  ' String-Array with 3 elements
a(22) = 42          ' 23rd element has value 42
Print Str(a(22))    ' Output 22nd element of variable a
s(0) = "Hallo Welt" ' Set text of first element
Print s(0)          ' Output this element
Example Dimensioning eeprom
eedim a(99) as byte       ' Byte-Array with 100 elements
eedim s[10](2) as string  ' String-Array with 3 elements of 10 Byte length each
                          ' (Strings in eeprom are identical, static and require a length identifier)
a(22) = 42                '  23rd element has value 42
Print Str(a(22))          ' Output 22nd element of variable a
s(0) = "Hallo Welt"       ' Set text of first element
Print s(0)                ' Output this element