1. How do I write a program using an array?
This example sets up an array of strings. To do this, declare an array type where the components
of the array are strings. Then declare a variable using the array type and put the strings into the
array. For example:
Ubercode 1 Class TestArray
type TStringArray[*:*] : array[*:*] of string
public function main()
MyStrings : TStringArray[*:*]
call Redim(1, 4, MyStrings)
MyStrings <- "Humpty"
MyStrings <- "Dumpty"
MyStrings <- "sat on the"
MyStrings <- "wall"
call Msgbox("Test String Array", Str(MyStrings))
The program just shown declares a one-dimensional type TStringArray. The array is
one-dimensional because it is declared using *:* for its size (the two stars represent the lower
and upper bound of the one-dimensional array). The array type consists of strings with a maximum
length of 200 characters per string. In function main a local array variable
MyStrings is declared, based on the array type. The array variable is declared as resizable
because it uses *:* for its size.
The code resizes the array to fit 4 strings (with a lower bound of 1 and an upper bound of 4),
then the assignment statements copy 4 strings into the array. Finally the Msgbox displays
the contents of the array.
2. How do I sort an array or a list?
Use the ArraySort and ListSort functions which work with arrays of strings and
lists of strings. If you have a large amount of data that needs to be sorted it is better to store
it in a table - the table type stores records and automatically keeps them sorted according to the