7.1.7 While...End
- Purpose
-
Flow control statement that iterates a sequence of statements as long as a specified condition is true.
- Syntax
While Condition [Statements] [Exit While] End [While]
- Arguments
-
- Condition
-
Write a conditional expression that evaluates to true or false.
- Statements
-
Write one or more statements to be executed while Condition is true. Begin each statement on a new line.
- Description
-
If Condition is true, all the statements in Statements are executed until the End statement is reached. Control then returns to the While statement and Condition is again evaluated. If Condition is still true, the process is repeated. If Condition is not true, execution moves to the statement following the End statement.
The Exit While statement can only be used within a While...End control structure as a means of exiting the While...End loop under a condition other than specified in Condition. You can write any number of Exit While statements anywhere in the While...End loop.
While...End loops can be nested to any level. Each End statement corresponds to the most recently executed While statement.
- Example
' Search for specified data among all the elements of a ' two-dimensional array variable. Dim array1( , ) Dim line : (Store the values in array variable array1) : line = 0 allCnt = GetArrayCount ( array1 ) While line < allCnt buff = InArray ( array1( line + 1 ) ,"1999" ,1 ,False ) If 0 < buff Then Exit While End If line = line + 1 End while
- JP1/Script version
-
Supported from JP1/Script 01-00.