Vulcan.NET Dynamic Arrays
FUNCTION Start() AS VOID
LOCAL a[10]
LOCAL b[10][20] AS USUAL // AS USUAL is optional for non-DIM arrays
LOCAL c AS INT
LOCAL d AS STRING
LOCAL e AS OBJECT
a[1] := 1
a[2] := 25.23
a[3] := "Hello World"
a[4] := Today()
a[6] := false
? a, a[1], a[2], a[3], a[4], a[5], a[6]
a[5] := 10
b[7][9] := "Hello world"
BEGIN SEQUENCE
c := b[7][9] // assign string into int
RECOVER USING e
? "Error is", e
END SEQUENCE
c := a[5]
? c
d := b[7][9]
? d
BEGIN SEQUENCE
? a[5,5] // invalid array element, a only has 1 dimension
RECOVER USING e
? "Error is", e
END SEQUENCE
a := b // now a is the same array as b, the original array in a is gone
? a[5,5] // invalid array element, a only has 1 dimension
b[5,5] := "Wow" // assignment to b's array affects a's because they're the same array reference
? a[5,5]
RETURN
|