DOUxx (Do Until)

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

The DOUxx operation code precedes a group of operations which you want to execute at least once and possibly more than once. 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 field name, a table name, an array element, a figurative constant, or a data structure name. Factor 1 and factor 2 must be the same data type.

On the DOUxx statement, you indicate a relationship xx. To specify a more complex condition, immediately follow the DOUxx statement with ANDxx or ORxx statements. The operations in the DOUxx group are processed once, and then the group is repeated until either:

The group is always processed at least once even if the condition is true at the start of the group.

In addition to the DOUxx operation itself, the conditioning indicators on the DOUxx and ENDDO statements control the DOUxx group. The conditioning indicators on the DOUxx statement control whether or not the DOUxx operation begins. The conditioning indicators on the associated ENDDO statement can cause a DO loop to end prematurely.

The DOUxx operation follows these steps:

  1. If the conditioning indicators on the DOUxx statement line are satisfied, the DOUxx operation is processed (step 2). If the indicators are not satisfied, control passes to the next operation that can be processed following the associated ENDDO statement (step 6).
  2. The DOUxx operation is processed by passing control to the next operation that can be processed (step 3). The DOUxx operation does not compare factor 1 and factor 2 or test the specified condition at this point.
  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 calculation operation following the associated ENDDO statement (step 6). Otherwise, the ENDDO operation is processed (step 5).
  5. The ENDDO operation is processed by comparing factor 1 and factor 2 of the DOUxx operation or testing the condition specified by a combined operation. If the relationship xx exists between factor 1 and factor 2 or the specified condition exists, the DO group is finished and control passes to the next calculation operation after the ENDDO statement (step 6). If the relationship xx does not exist between factor 1 and factor 2 or the specified condition does not exist, the operations in the DO group are repeated (step 3).
  6. The statement after the ENDDO statement is processed when the conditioning indicators on the DOUxx or ENDDO statements are not satisfied (steps 1 or 4), or when the relationship xx between factor 1 and factor 2 or the specified condition exists at step 5.

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

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

Figure 307. DOUxx Operations
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *
 *  The DOUEQ operation runs the operation within the DO group at
 *  least once.
C
C     FLDA          DOUEQ     FLDB
C
 *
 *  At the ENDDO operation, a test is processed to determine whether
 *  FLDA is equal to FLDB.  If FLDA does not equal FLDB, the
 *  preceding operations are processed again.  This loop continues
 *  processing until FLDA is equal to FLDB.  When FLDA is equal to
 *  FLDB, the program branches to the operation immediately
 *  following the ENDDO operation.
C
C                   SUB       1             FLDA
C                   ENDDO
C
 *
 *  The combined DOUEQ ANDEQ OREQ operation processes the operation
 *  within the DO group at least once.
C
C     FLDA          DOUEQ     FLDB
C     FLDC          ANDEQ     FLDD
C     FLDE          OREQ      100
C
 *
 *  At the ENDDO operation, a test is processed to determine whether
 *  the specified condition, FLDA equal to FLDB and FLDC equal to
 *  FLDD, exists.  If the condition exists, the program branches to
 *  the operation immediately following the ENDDO operation.  There
 *  is no need to test the OREQ condition, FLDE equal to 100, if the
 *  DOUEQ and ANDEQ conditions are met.  If the specified condition
 *  does not exist, the OREQ condition is tested.  If the OREQ
 *  condition is met, the program branches to the operation
 *  immediately following the ENDDO.  Otherwise, the operations
 *  following the OREQ operation are processed and then the program
 *  processes the conditional tests starting at the second DOUEQ
 *  operation.  If neither the DOUEQ and ANDEQ condition nor the
 *  OREQ condition is met, the operations following the OREQ
 *  operation are processed again.
C
C                   SUB       1             FLDA
C                   ADD       1             FLDC
C                   ADD       5             FLDE
C                   ENDDO


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