EasyManua.ls Logo

Radio Shack TRS-80 Model 4 - Page 304

Radio Shack TRS-80 Model 4
418 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
WHILE
....
WEND
Statement
WHILE
expression
{loop statements}
WEND
Execute a series of statements
in
a loop
as
long as a given condition
is true.
If
expression
is
not zero (true), BASIC executes loop statements until
it encounters a WEND. BASIC returns to the WHILE statement and
~.
checks expression.
If
it is still true, BASIC repeats the process.
If
it
is
not true, execution resumes with the statement following the WEND
statement.
WHILE/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, and
an
unmatched WEND
causes a "WEND without WHILE" error.
Sample Program
90
'BUBBLE
SORT ARRAY A$
100
FLIPS=l
'FORCE
ONE
PASS THRU LOOP
110
WHILE
FLIPS
115
FLIPS=0
120
FOR
1=1
TO
J-l
130
IF
A$(l):>A$(I+l>THEN
SWAP
A$(l),
A$(I+l):
FLIPS=l
1
L10
NE){T I
150
WEND
This program sorts the elements
in
array
A$.
Control falls out of the
WHILE loop when
no
more SWAPS are performed
on
line 130.
2-178

Other manuals for Radio Shack TRS-80 Model 4

Related product manuals