## 2.2.3 Arrays

An array is a group of contiguous storage locations associated with a single symbolic name, the array name. The individual storage locations, array elements, are referenced by a subscript appended to the array name.

An array can have from one to seven dimensions. For example, a column of figures is a one-dimensional array. A table with more than one column of figures is a two-dimensional array. To refer to a specific value in this array, you must specify both its row and column numbers. A table of figures that covers several pages is a three-dimensional array. To locate a value in this array, you must specify the page, row, and column numbers.

The following statements can be used to establish arrays:

- Type declaration

- DIMENSION

- COMMON

These statements can contain array declarators that define the name of the array, the number of dimensions in the array, and the number of elements in each dimension.

Associating Arrays

Two or more arrays are associated when each one is associated with the same storage location. They are partially associated when part of the storage associated with one array is the same as part or all of the storage associated with another array.

Association and partial association occur when you use COMMON or EQUIVALENCE statements, map declarations (within structure declarations), or actual arguments and dummy arguments in subprogram references.

If arrays with different data types are associated (or partially associated) with the same storage location, and the value of one array is defined (for example, by assignment), the value of the other array becomes undefined. This happens because an element of an array is considered defined only if the storage associated with it contains data of the same type as the array name.

The DATA statement defines an array element or an entire array before program execution. During program execution, array elements are defined by an assignment or input statement, and entire arrays are defined by input statements.

For More Information:

- On type declaration statements, see Section 4.5.

- On the DIMENSION statement, see Section 4.6.

- On the COMMON statement, see Section 4.3.

- On the EQUIVALENCE statement, see Section 4.7.

- On map declarations, see Section 4.17.3.

- On the DATA statement, see Section 4.4.

- On the arrangement of array elements in storage, see Section 2.2.3.3.

Previous Page Next Page Table of Contents