while Statement

Top  Previous  Next

Repeats a loop while an expression is true.

Syntax

while (expression)

   statement

Description

expression is evaluated and if it is true, statement is executed. The expression is evaluated again and the statement executed until the expression evaluated is false. When expression is false, CellScript executes next statement in the program.

Remarks

When working with while statements it is very important that variables in the expression change, otherwise expression will always be true and the loop will never end.

Examples

var count = 0;

while (count < 10) {

   Net.write(count + " ; ");

   count++;        // Returns 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ;