Go to the first, previous, next, last section, table of contents.

Array Types

ARRAY { <indextype> "," ... } OF <slottype> ";"

<indextype> must be an ordinal type (see section Ordinal Types). The common case is an integer subrange such as [1..numslots], but Modula-3 programs frequently use user-defined enumerations as well.

<slottype> can be any Modula-3 type, even another array.

Here are some examples of array types:

TYPE
  OneDimArray  = ARRAY [1..20] OF REAL;
  OneDimArray2 = ARRAY ['A'..'Z'] OF INTEGER;
  TwoDimArray  = ARRAY [1..20], [1..40] OF BOOLEAN;
  TwoDimArray2 = ARRAY [1..20] OF ARRAY [1..40] OF BOOLEAN;

The built-in functions FIRST, LAST, and NUMBER can be used with array types and variables to return the index of the first and last slot and number of slots, respectively. For example, FIRST(OneDimArray) = 1; NUMBER(OneDimArray2) = 26.


Go to the first, previous, next, last section, table of contents.