DOWxx (Do While)

Free-Form Syntax (not allowed - use the DOW operation code)
Code Factor 1 Factor 2 Result Field Indicators
DOWxx Comparand Comparand

The DOWxx operation code precedes a group of operations which you want to process when a given condition exists. To specify a more complex condition, immediately follow the DOWxx statement with ANDxx or ORxx statements. An associated ENDDO statement marks the end of the group. For further information on DO groups and the meaning of xx, see Structured Programming Operations.

Factor 1 and factor 2 must contain a literal, a named constant, a figurative constant, a field name, a table name, an array element, or a data structure name. Factor 1 and factor 2 must be of the same data type. The comparison of factor 1 and factor 2 follows the same rules as those given for the compare operations. See Compare Operations.

In addition to the DOWxx operation itself, the conditioning indicators on the DOWxx and ENDDO statements control the DO group. The conditioning indicators on the DOWxx statement control whether or not the DOWxx operation is begun. The conditioning indicators on the associated ENDDO statement control whether the DOW group is repeated another time.

The DOWxx operation follows these steps:

  1. If the conditioning indicators on the DOWxx statement line are satisfied, the DOWxx operation is processed (step 2). If the indicators are not satisfied, control passes to the next operation to be processed following the associated ENDDO statement (step 6).
  2. The DOWxx operation is processed by comparing factor 1 and factor 2 or testing the condition specified by a combined DOWxx, ANDxx, or ORxx operation. If the relationship xx between factor 1 and factor 2 or the condition specified by a combined operation does not exist, the DO group is finished and control passes to the next calculation operation after the ENDDO statement (step 6). If the relationship xx between factor 1 and factor 2 or the condition specified by a combined operation exists, the operations in the DO group are repeated (step 3).
  3. Each of the operations in the DO group is processed.
  4. If the conditioning indicators on the ENDDO statement are not satisfied, control passes to the next operation to run following the associated ENDDO statement (step 6). Otherwise, the ENDDO operation is processed (step 5).
  5. The ENDDO operation is processed by passing control to the DOWxx operation (step 2). (Note that the conditioning indicators on the DOWxx statement are not tested again at step 1.)
  6. The statement after the ENDDO statement is processed when the conditioning indicators on the DOWxx or ENDDO statements are not satisfied (steps 1 or 4), or when the relationship xx between factor 1 and factor 2 of the specified condition does not exist at step 2.

See LEAVE (Leave a Do/For Group) and ITER (Iterate) for information on how those operations affect a DOWxx operation.

For more information, see Compare Operations or Structured Programming Operations.

Figure 309. DOWxx Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *
 *  The DOWLT operation allows the operation within the DO group
 *  to be processed only if FLDA is less than FLDB.  If FLDA is
 *  not less than FLDB, the program branches to the operation
 *  immediately following the ENDDO operation.  If FLDA is less
 *  than FLDB, the operation within the DO group is processed.
C
C     FLDA          DOWLT     FLDB
C
 *
 *  The ENDDO operation causes the program to branch to the first
 *  DOWLT operation where a test is made to determine whether FLDA
 *  is less than FLDB.  This loop continues processing until FLDA
 *  is equal to or greater than FLDB; then the program branches
 *  to the operation immediately following the ENDDO operation.
C
C                   MULT      2.08          FLDA
C                   ENDDO
C
 *  In this example, multiple conditions are tested.  The combined
 *  DOWLT ORLT operation allows the operation within the DO group
 *  to be processed only while FLDA is less than FLDB or FLDC. If
 *  neither specified condition exists, the program branches to
 *  the operation immediately following the ENDDO operation. If
 *  either of the specified conditions exists, the operation after
 *  the ORLT operation is processed.
C
C     FLDA          DOWLT     FLDB
C     FLDA          ORLT      FLDC
C
 *  The ENDDO operation causes the program to branch to the second
 *  DOWLT operation where a test determines whether specified
 *  conditions exist.  This loop continues until FLDA is equal to
 *  or greater than FLDB and FLDC; then the program branches to the
 *  operation immediately following the ENDDO operation.
C
C                   MULT      2.08          FLDA
C                   ENDDO


[ Top of Page | Previous Page | Next Page | Contents | Index ]