- Code: Select all
// TestArray.cls
Ubercode 1 class TestArray
type TStringArray[*:*] : array[*:*] of string[200]
public function main()
var
MyStrings : TStringArray[*:*]
code
call Redim(1, 4, MyStrings)
MyStrings[1] <- "Humpty"
MyStrings[2] <- "Dumpty"
MyStrings[3] <- "sat on the"
MyStrings[4] <- "wall"
call Msgbox("Test String Array", Str(MyStrings))
end function
end class
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.
