Example

// Declares an array initialized with the names of days of the week

DayArray is array of strings = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]

// Handles the array

DayArray[2] // Returns "Tuesday"

// Declares an array of integers

Syntax

Declaring a one-dimensional array

 

<Array name> is array [<growth>] [ [<Dimension 1>] ] <Type of array elements>

Example:

arrString is array <growth=N> [10] strings

arrInt is array [5] ints

<Array name> is array [<growth>] of [<Dimension>] <Type of array elements>

 

Examples

ValueArray is array of int

// Fills the array of integers by adding values

Add(ValueArray, 5)

Add(ValueArray, 10)

Add(ValueArray, 15)

// Browses the array values

FOR EACH x OF ValueArray

// x is successively equal to 5, 10, 15

...

END

 

MyArray is array of 5 by 2 int

VariableReset(MyArray)

 

// Declares an array of integers

ValueArray is array <growth=1> of int

// Enlarges the array to insert the value 1: 10

ValueArray[1] = 10

// Enlarges the array to insert the value 2: 20

ValueArray[2] = 20

// Enlarges the array to insert the value 3: 30

ValueArray[3] = 30

// Browses the array values

FOR EACH x OF ValueArray

// x is successively equal to 10, 20, 30

END

 

 

// Declares an array of integers

ValueArray is array <growth=N> of int

// Enlarges the array to insert the value 1: 10

ValueArray[1] = 10

// Enlarges the array to insert the value 5: 50

// The values 2, 3 and 4 are initialized to 0

ValueArray[5] = 50

// Browses the array values

FOR EACH x OF ValueArray

// x is successively equal to 10, 0, 0, 0, 50

END

 

// Declare an Array of arrays

arrMyArray is array of strings

nArrIndex is int

 

nArrIndex = Add(arrMyArray)

Add(arrMyArray[nArrIndex], "January")

Add(arrMyArray[nArrIndex], "300")

nArrIndex = Add(arrMyArray)

Add(arrMyArray[nArrIndex], "February")

Add(arrMyArray[nArrIndex], "600")

 

Trace(arrMyArray[1,1]) // Displays "January"

Trace(arrMyArray[1,2]) // Displays "300"