2.2.2 Variables

A variable is represented by a symbolic name associated with a single storage location. The value of the variable is the value currently stored in that location; you can change its value at any point in a program by assigning a new value to it.

Variables are classified by data type, as constants are. The data type of a variable indicates the type of data it contains, its precision, and its storage requirements. When data of any type is assigned to a variable, it is converted, if necessary, to the data type of the variable.

The data type of a variable can be established by any of the following:

All variables are scalar references because they resolve into single data items having a data type.

Associating Variables

Two or more variables are associated with each other when each is associated with the same storage location. They are partially associated when part (but not all) of the storage associated with one variable is the same as part or all of the storage associated with another variable.

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 variables of different data types are associated (or partially associated) with the same storage location, and the value of one variable is defined (for example, by assignment), the value of the other variable becomes undefined. This occurs because a variable is defined only if the storage associated with it contains data of the same type as the name.

A variable can be defined before program execution by a DATA statement or during execution by an assignment or input statement.

For More Information:


Previous Page Next Page Table of Contents