WHILE...WEND (Statement)


Repeat a block of statements in a pretest loop.


WHILE [<conditional expression>]
:
WEND


This statement repeats a block of statements between WHILE and WEND while <conditional expression> is true.
If <conditional expression> is omitted, the condition will be assumed as true (not 0) so that this statement falls into an infinite loop.
Branching to the midst of the WHILE...END statement block, e.g., using a GOTO statement, executes the statement block until the WEND statement is encountered. Control then returns to the WHILE statement and after that, this statement block is executed as usual.
There is also a DO WHILE...LOOP statement that is functionally equivalent to this statement, so using only the DO WHILE...LOOP is recommended.



DEFINT li1, li2, li3, li4, li5, li6, li7, li8, li9
DO WHILE li1 > li2
'Repeat in a pretest loop
IF li1 = 4 THEN EXIT DO
'If li1=4, exit from DO...LOOP
FOR li3 = 0 TO 5
'Repeat the process of FOR...NEXT 5 times
FOR li4 = li5 TO li6
'Repeat the process of FOR...NEXT while adding 1 to the
'value of li5 each time the process is done until li5
'becomes the value of li6
FOR li7 = 1 TO li8 STEP 2
'Repeat the process of FOR...NEXT while adding 2 to the
'value starting with 1 each time the process is done
'until the value becomes li8
IF li2 = 2 THEN EXIT FOR
'If li2=2, exit from FOR...NEXT
WHILE li2 < li9
'Repeat in a pretest loop
GOSUB *samp2
li9 = li9 + 1
WEND
'Call a GOSUB *samp2 statement while li2 < li9
NEXT li7
'Repeat
NEXT
'Repeat
NEXT
'Repeat
li9 = 0
REPEAT
'Repeat in a posttest loop
GOSUB *samp2
li9 = li9 + 1
UNTIL li9 < 5
'Call a GOSUB *samp2 statement until li9 < 5
LOOP
'Repeat


Top