while

while -- iterates, evaluating a statement.

Syntax

while (condition) statement

		

Arguments

condition

Any Gamma or Lisp expression.

statement

Any Gamma or Lisp statement.

Returns

The value of condition at the final iteration.

Description

This function iterates until its condition evaluates to nil, evaluating the statement at each iteration. The condition is evaluated before the statement, so it is possible for a while loop to iterate zero times.

Example

    Gamma> x = 0;
    0
    Gamma> while (x < 5) { princ (x, "\n"); x++; }
    0
    1
    2
    3
    4
    4
    Gamma> x;
    5
    Gamma> 

See the Emulating the PID Loop section of the PID Emulator chapter, or the Common: The Text Message Display section of the Common: The Text Message Display chapter, or the Common: Starting and Stopping the Cascade TextLogger section of the Log Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

See Also

for, if, Statements

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.