CL Command Reference - ENDDO

CL Command List > ENDDO Reference

Description:

The End Do (ENDDO) command is used with the DO command to identify a group of commands that are processed together as a group. The ENDDO command specifies the end of the Do group that is started with an associated DO command. The ENDDO command must be specified after the last command in the Do group.

When Do groups are nested, each group must have its own ENDDO command at its end. Every ENDDO command must be associated with a DO command; if too many ENDDO commands occur in the CL procedure source, a message is issued and the program is not created.

Restrictions: This command is valid only within a CL procedure.


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.