While...Wend

Use While...Wend statements to execute a series of statements, as long as a given condition is true.

Syntax

While condition

[statements]

Wend

Parameter

Description

Condition

Required. The condition is any expression that evaluates to true or false. False is assumed to be a zero value. Any non-zero value is assumed to be true.

Statements

One or more statements executed while the condition is true.

If condition is true, the statements within the While block are executed. When the Wend statement is encountered, control returns to the While statement and condition is again evaluated. If condition is still true, the process repeats. If it is false, execution resumes with the statement which follows the Wend statement.

You can nest While...Wend loops to any level. Each Wend matches the most recent While.

Note Keep in mind that you can start an endless loop if you specify a condition that can never be satisfied. The system cannot syntactically detect an endless loop, so if you create one, the program will lock up and you will have to kill the program.

(Ellipses in the following examples represent additional statements, not shown.)

While(10 > #value)
   ...
   While (#new = 1)
       ... 
   Wend
   ... 
Wend

You do not have to use tabs to indent nested While…Wend statements. Tabs are used in these examples, to help identify statement blocks. You may want to also use tabs in your code to make the source easier to read.

See also