Uploaded by raj.oracledba

WEND

advertisement
GW-BASIC User's Guide
WHILE ... WEND Statement
Purpose:
To execute a series of statements in a loop as long as a given condition is true.
Syntax:
WHILE expression
.
.
.
[loop statements]
.
.
.
END
Comments:
If expression is nonzero (true), loop statements are executed until the WEND statement is
encountered. GW-BASIC then returns to the WHILE statement and checks expression. If it is still
true, the process is repeated.
If it is not true, execution resumes with the statement following the WEND statement.
WHILE and WEND loops may be nested to any level. Each WEND matches the most recent WHILE.
An unmatched WHILE statement causes a "WHILE without WEND" error. An unmatched WEND
statement causes a "WEND without WHILE" error.
Examples:
90 'BUBBLE SORT ARRAY A$
100 FLIPS=1
110 WHILE FLIPS
115 FLIPS=0
120 FOR N=1 TO J-1
130 IF A$(N)>A$(N+1) THEN SWAP A$(N), A$(N+1): FLIPS=1
140 NEXT N
150 WEND
file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/WHILEWEND.html28/03/2004 21.29.52
Download