User Tools

Site Tools


ibm:vm370-lib:cmshelp:loop.helpexc

LOOP

EXEC Interpreter

loop.helpexc.txt
&LOOP STATEMENT                                                  EXEC statement

Use the &LOOP control statement to describe a loop in an EXEC procedure,
including the conditions for exit from the loop.  The format of the &LOOP
control statement is:
+-----------+-----------------------------------------------------------------+
| &LOOP     | n|-label  m|condition                                           |
+-----------+-----------------------------------------------------------------+
where:

n        is a positive integer from 0 to 4095 that indicates the number of
         executable and nonexecutable lines in the loop.  These lines must
         immediately follow the &LOOP statement.

-label   specifies that all of the lines following the &LOOP statement down to,
         and including the line with the specified label, are to be executed in
         the loop.  The first character of the label must be a hyphen, and it
         must be the first token on a line.  The remainder of the line may
         contain an executable statement, or it may be null.  The label is
         case-sensitive

m        is a positive integer from 0 to 4095 that indicates the number of
         times the loop is to be executed.

condition
         specifies the condition that must be met.  The syntax of the exit
         condition is the same as that in the &IF statement, that is:
            tok1|&$|&*  operator  tok2|&$|&*


Usage Notes:

1.  When loop execution is complete, control passes to the next statement
    following the end of the loop.

2.  The condition is always tested before the loop is executed.  If the
    specified condition is met, then the loop is not executed.  For example,
    the statement:
       &LOOP 3 &COUNT = 100
    specifies that the next three lines are interpreted until the value of
    &COUNT is 100.

3.  Loops may be nested up to four levels deep.  All nested loops may end at
    the same label.

4.  A loop is closed when the requirements for termination specified in the
    &LOOP statement are met, or when control is transferred outside the scope
    of the loop (via &GOTO or &SKIP).
ibm/vm370-lib/cmshelp/loop.helpexc.txt ยท Last modified: 2023/08/06 13:36 by Site Administrator