BB___WHILE_WEND

=WHILE..WEND= toc

Description
> WHILE..WEND will cause the code between the WHILE and WEND statements to execute repeatedly as long as the expression evaluates to true. **Use WHILE/WEND when you want to skip the included code if the expression initially evaluates to false**. If the condition evaluates to false, the code will exit the loop.

> The //expression// is supposed to be boolean, with lack of boolean type in JB/LB, integer expression will do (0 false, any other is true).

> The code included between the WHILE and WEND is optional.

> See also FOR/NEXT and DO..LOOP for other loop contructs.

Syntax
>> //{code statements...(optional)}// > wend
 * 1) while //expression//

Hints
> Normally, a loop will execute over and over until a condition evaluates to false, at which point the loop is ended. DO NOT ISSUE A GOTO STATEMENT TO EXIT A WHILE..WEND LOOP BEFORE THE WHILE CONDITION EVALUATES TO FALSE. If it is necessary to exit a loop before it has finished, issue an EXIT WHILE command.

> However, you may branch from a WHILE..WEND loop using GOSUB, FUNCTION and SUB. This is because when any of these procedures finishes, program execution is returned to the statement within the loop following the call to the procedure. The WEND statement will be encountered and the WHILE statement will once again evaluate the condition.

Example
code format="vbnet" a = 3 i = 0 while i <> a       i = i + 1 print i   wend

print

' Loop until a valid response is solicited while val(age$) = 0 input "How old are you?"; age$ if val(age$) = 0 then print "Invalid response. Try again." wend

print ' Exiting a WHILE..WEND loop prematurely i = 0 while i < 100 i = i + 4 print i       if i > 13 then exit while wend

print

end code

Useful Functions
code format="vbnet" Place a useful function using this command here code