DO (Do) Command Description

DO Command syntax diagram

Purpose

The Do (DO) command allows the user to group commands within a CL program. It is used with the ENDDO command to identify a group of commands that are run together as a group. Usually, the DO command specifies the starting of a group of commands that are run as a result of a decision made by the processing of an IF command. However, the DO command does not have to be associated with an IF command. When used with an IF command, the DO command can be either the true part of the decision (that is, the value of the THEN parameter of the IF command), or the false part of a decision (on the ELSE command). Every Do group must be ended by the ENDDO command. Do groups can be nested within other Do groups, but each group must have an ENDDO command to end its level of nesting.

Restriction: This command is valid only within a CL program. Up to 10 levels of Do groups can be nested within each other.

There are no parameters for this command.

Examples for DO

Example 1: Processing a Group of Commands

DO
   *
   *   (group of CL commands)
   *
ENDDO

The commands between the DO and ENDDO commands are processed once, as a group of commands.

Example 2: Processing a Group of Commands

If &SWITCH DO
   *
   *   (group of CL commands)
   *
ENDDO

The commands between the DO and ENDDO commands are processed if the value in the logical variable &SWITCH is '1'. If &SWITCH is not '1', then control passes immediately to the next command following the ENDDO command.

Error messages for DO

None