| |||
| Home > RealView Debugger Keywords > Alphabetical keyword reference > while | |||
Evaluates an expression and executes one or more statements until the expression evaluates to False.
while (expression) /* while this expression is True */ {statement; /* execute this statement */ [statement;]... /* and these additional statements */ }
where:
expressionThe expression to be evaluated at the start of each loop.
The while statement evaluates an expression and executes the following statement or statements until the expression evaluates to False.
The while statement must be followed by an expression
in parentheses. As long as the expression evaluates to True, all
following statements are repeatedly executed. When the expression
evaluates to False, all statements are bypassed and execution continues at
the next statement outside the while loop. If you have
more than one statement in the loop these must be enclosed in curly
braces ({}).
This example shows how to use while in a macro:
define /R void whileloop()
{
int x;
x = 1;
while (1) {
$printf "Iteration: %d\n", x$;
if (x > 10) {
$printf "Done!\n"$;
break;
} else if (x==5) {
$printf "Halfway there...\n"$;
}
x++;
}
}
.