while command (C and C++)

The while command enables you to repeatedly perform the body of a loop until the specified condition is no longer met or evaluates to false. The while keyword must be lowercase and cannot be abbreviated.

Read syntax diagramSkip visual syntax diagramwhile(expression)command;
expression
A valid z/OS® Debugger C expression.
command
A valid z/OS Debugger command.

The expression is evaluated to determine whether the body of the loop should be performed. If the expression evaluates to false, the body of the loop never executes. Otherwise, the body does execute. After the body has been performed, control is given once again to the evaluation of the expression. Further execution of the action depends on the value of the condition.

A break command can cause the execution of a while command to end, even when the condition does not evaluate to false.

Usage notes

  • If you are replaying recorded statements by using the PLAYBACK commands, then you cannot use the while command.

Examples

  • List the values of x starting at 3 and ending at 9, in increments of 2.
    x = 1;
    while (x +=2, x < 10)
      LIST x;
  • While --index is greater than or equal to zero (0), triple the value of the expression item[index].
    while (--index >= 0) {
      item[index] *= 3;
      printf("item[%d] = %d\n", index, item[index]);
    }