Arrays

Multiple variables of the same type can be stored in an array data structure.

The following types are supported with arrays:

  • INT
  • STRING
  • FILE

Declare an array by specifying the type of its elements:

INT[] intArray;
STRING[] stringArray;
FILE[] fileArray;

Arrays can be initialised with curly braces as shown here. The first element in the braces is element 0 in the array:

INT[] intArray := {1, 2, 42};
INT[][] intArray2 := { {1, 2, 42}, {9, 72} };

PRINT("intArray[0] is: ", intArray[0], "\n");
PRINT("intArray[2] is: ", intArray[2], "\n");
  intArray[0] is: 1
  intArray[2] is: 42

Array overview

  • Arrays can be single-dimensional or jagged.
  • Arrays will grow as required to fit the index being set.
  • Arrays are not passed by reference: assigning one array to another will make a new copy.
  • The default size of an array is zero.
  • Arrays are automatically expanded when the index (both when accessing or assigning) is outside the current range.
  • Arrays are zero indexed.
  • Arrays are compatible with External API calls.

See Also