Do Group (DO)
Where allowed to run:
|
Parameters Examples Error messages |
The Do (DO) command allows you to group commands within a CL program or ILE CL procedure; it is used with the ENDDO command to identify a group of commands that are processed together as a group. Usually, the DO command specifies the starting of a group of commands that are processed 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.
Restrictions: This command is valid only within a CL program or ILE CL procedure.
There are no parameters for this command.
Top |
Examples
Example 1: Processing a Group of Commands Unconditionally
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 Conditionally
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.
Top |
Error messages
None
Top |