Syntax: while loop

The while statement is another loop like the for loop. However, for is normally used when you know the number of times that you want to run the loop. The while loop is used when you don’t know how many times to run the loop.

Syntax:

while ( expression )
{
 list of statements
}

When the while loop is executed, the following sequence of operations occur repeatedly:

  1. The expression is evaluated and if it is false the loop is complete and the next statement after the loop is executed. If the expression evaluates to true the body of the loop is executed.

  2. The list of statements is executed, and then the loop begins again.

Remarks:

while – is a keyword, used to start a while loop.

expression – is any valid OpusScript expression.

list of statements – a list of OpusScript statements. One of the statements must allow the loop to complete, otherwise you will have an infinite loop.

( ) – the expression must be surrounded by round brackets.

{ } – the list of statements must be surrounded by curly brackets.

image\Script_Button.jpgExamples