for command (C and C++)

The 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.

Read syntax diagramSkip visual syntax diagram
>>-for--(--+------------+--;--+------------+--;----------------->
           '-expression-'     '-expression-'      

>--+------------+--)--command--;-------------------------------><
   '-expression-'                  

expression
A valid Debug Tool C and C++ expression.
command
A valid Debug Tool command.

Debug Tool 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.

Debug Tool 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.

Debug Tool 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

Examples