for command (C and C++)
for command provides iterative looping similar
to the C and C++ for statement.
It enables you to do the following: - Evaluate an expression before the first iteration of the command ("initialization").
- Specify an expression to determine whether the command should be performed again ("controlling part").
- Evaluate an expression after each iteration of the command.
- Perform the command, or
block, if the controlling part does not evaluate to false.
The for keyword must be lowercase and cannot be
abbreviated.
- expression
- A valid z/OS® Debugger C and C++ expression.
- command
- A valid z/OS Debugger command.
z/OS Debugger evaluates the first expression only before the command is performed for the first time. You can use this expression to initialize a variable. If you do not want to evaluate an expression before the first iteration of the command, you can omit this expression.
z/OS Debugger evaluates
the second expression before each execution
of the command. If this expression evaluates to false, the command
does not run and control moves to the command following the for command.
Otherwise, the command is performed. If you omit the second expression,
it is as if the expression has been replaced by a nonzero constant
and the for command is not terminated by failure
of this expression.
z/OS Debugger evaluates the third expression after each execution of the command. You might use this expression to increase, decrease, or reinitialize a variable. If you do not want to evaluate an expression after each iteration of the command, you can omit this expression.
A break command can cause the execution of a for command
to end, even when the second expression does not evaluate to false.
If you omit the second expression, you must use a break command
to stop the execution of the for command.
Usage notes
- The
forcommand cannot be used while you replay recorded statements by using thePLAYBACKcommands.
Examples
- The following
forcommand lists the value ofcount20 times. Theforcommand initially sets the value ofcountto 1. After each execution of the command,countis incremented.for (count = 1; count <= 20; count++) LIST TITLED count;Alternatively, the preceding example can be written with the following sequence of commands to accomplish the same task.count = 1; while (count <= 20) { printf("count = %d\n", count); count++; } - The following
forcommand does not contain an initialization expression.for (; index > 10; --index) { varlist[index] = var1 + var2; printf("varlist[%d] = %d\n", index, varlist[index]); }
