Tandy 1000 Basic Reference Manual page 343

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I BASIC Ke.ywords
WHILE
...
WEND
Statement
WHILE
expression
WEND
Executes a series of statements in a loop as long as a given con-
dition is true.
Expression
is any numeric or string expression, usually making
logical or relational comparisons.
If
expression
is true, BASIC executes the statements after the
WHILE statement until it encounters a WEND statement. Then
BASIC returns to the WHILE statement and checks
expression.
If it is still true, BASIC repeats the process. If it is not true, exe-
cution resumes with t h e statement following t h e WEND
statement.
You may nest WHILE/WEND loops to any level. Each WEND
matches the most recent WHILE. An unmatched WHILE state-
ment causes a "WHILE without WEND" error, and an un-
matched WEND causes a "WEND without WHILE" error.
Sample Program
9 0 " B U B B L E S O R T A R R A Y
A $
1 0 0 F L I P S = l " F O R C E O N E P A S S T H R U L O O P
1 1 0
W H I L E F L I P S
1 1 5
F L I P S = 0
1 2 0
F O R I = l
TO
J-1
1 3 0
IF A$(I)>A$(I+l)THEN
S W A P
A $ < I ) ,
1 4 0
N E X T
I
1 5 0 W E N D
A $ ( I + 1
1 :
F L I P S = l
This program sorts the elements in array A$. Control falls out of
the WHILE loop when no more swaps are performed on Line
130.
341

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents