[Next] [Up] [Previous]

The DIM Statement

The DIM (DIMENSION) statement has the same form as a type declaration statement, and can do everything for a variable except specify its type that such a statement can do.


       DIM I(3)/78,22,36/


       INTEGER I(3)/78,22,36/

achieve the same result, unless a statement in the same program with the DIM statement were to declare I as of a type other than INTEGER. Since I is intended to be of type INTEGER, this fact is not mentioned explicitly, since it is already the default.

A variable can be given a type, then a dimension, and then initial values, in that order only, by successive statements. But these statements need not be type, DIM, and DATA in that order.

However, every variable in a DIM statement must be given its true dimension in that statement, since that is where the dimensions of variables mentioned in that statement are expected to be found. Thus, DIM is not exactly the same as DATA in general.

The DATA statement initializes variables in the same way as a type declaration statement. However, if a subscript appears after the name of a variable being initialized, it DOES NOT dimension that variable; instead, that variable must already have been dimensioned, and the subscript values indicate the starting point of the initialization taking place in that statement.

Each item in the list of initial values is assumed to begin in storage at the same point as the array element it corresponds to, but these items are not truncated if they exceed it in length. Thus, a single long character string can be used to initialize a whole array of CHARACTER*1 elements, for example.

[Next] [Up] [Previous]