### 7.1.3.1 ASSIGN Statement

The ASSIGN statement assigns a statement label value to an integer variable. It takes the following form:

  ASSIGN label TO var
  label
  Is the label of a branch target or FORMAT statement in the same scoping unit as the ASSIGN statement.
  var
  Is a scalar integer variable.

Rules and Behavior

When an ASSIGN statement is executed, the statement label is assigned to the integer variable. The variable is then undefined as an integer variable and can only be used as a label (unless it is later redefined with an integer value).

The ASSIGN statement must be executed before the statements in which the assigned variable is used.

Examples

The following example shows ASSIGN statements:

    INTEGER ERROR
    ...
    ASSIGN 10 TO NSTART
    ASSIGN 99999 TO KSTOP
    ASSIGN 250 TO ERROR

Note that NSTART and KSTOP are integer variables implicitly, but ERROR must be previously declared as an integer variable.

The following statement associates the variable NUMBER with the statement label 100:

    ASSIGN 100 TO NUMBER

If an arithmetic operation is subsequently performed on variable NUMBER (such as follows), the run-time behavior is unpredictable:

    NUMBER = NUMBER + 1

To return NUMBER to the status of an integer variable, you can use the following statement:

    NUMBER = 10

This statement dissociates NUMBER from statement 100 and assigns it an integer value of 10. Once NUMBER is returned to its integer variable status, it can no longer be used in an assigned GO TO statement.

Previous Page Next Page Table of Contents