COMTRAN Reconstruction

F28-8043 · June 1960

Page 51

PDF page 57 of 124. Download the scanned PDF

The page as scanned

The scan of PDF page 57 of F28-8043
Select the scan to open it at full size.

The text read off it

[page 51]

        SET i = p.
START.  DO rtn.
        IF i = r THEN GO TO NEXT.
        ADD q TO i.
        GO TO START.
NEXT.   .
        .
        .

Each of the loop control parameters p, q and r may be either of the following:

  1. A literal having an integer value.
  2. The name of a field defined as an integer.

The following example shows a DO command of this form:

DO RATE.UPDATE.CALC FOR STATE = 1(1)50.

In this example, each item in a rate table is being updated. The table contains fifty entries—a rate for each state. The procedure RATE.UPDATE.CALC might appear as:

RATE.UPDATE.CALC.  SET RATE (STATE) = RATE (STATE) *
     ADJUST.FACTOR + FLAT.AMT.

This procedure will be executed repeatedly, once for each value of the index STATE (from 1 through 50). The value of STATE (in the DO command) at any given time specifies which table item is to be dealt with in the procedure. Thus, the variable RATE is said to be subscripted by the index STATE.

When it is desired to control two indices during the execution of a DO, thus providing a loop within a loop, the command takes the form:

DO procedure.name FOR index.name.1 = p.1(q.1)r.1, index.name.2 = p.2(q.2)r.2

In this case, "index.name.1" and "index.name.2" are initially set to p.1 and p.2 respectively. Each time the inner loop is executed, index.name.2 is incremented by q.2 until it equals r.2; thereupon, index.name.2 is reset to p.2 and index.name.1 is set to p.1 + q.1. Control is returned to the inner loop and the process is repeated. When index.name.1 is equal to r.1, control passes to the clause or sentence which follows the DO.

A maximum of three indices may be controlled with the DO command. Again, the rightmost index is the one which varies most rapidly. The following example illustrates the DO controlling three indices:

DO COMPUTATION FOR HOURS = 1(1)12, MINUTES = 1(1)60,
     SECONDS = 1(1)60.

In this case, the procedure COMPUTATION is executed with the index SECONDS being incremented from 1 through 60 (in increments of 1), at which time MINUTES is increased by 1 and SECONDS again runs to 60. When the index MINUTES reaches 60 the index HOURS is incremented by 1, and so on. After HOURS has reached 12, the loop is completed and control passes to the operation following the DO. The subroutine will have been executed 60x60x12 times.