WHILE
WHILE expr
Starts a WHILE … WEND loop.
A While-loop loops as long as the test condition expr
evaluates to true. SmallBASIC starts by evaluating the expression. If
the expression is nonzero (true), the next command in the loop is
executed. If the expression is zero (false), control passes to the first
command following the next WEND command. When SmallBASIC encounters the
WEND command, it reevaluates the expression parameter to the most recent
WHILE. If that parameter is still nonzero (true), the process is
repeated; otherwise, execution continues at the next command.
WHILE/WEND loops may be nested to any level of complexity, but there must be a WEND for each WHILE.
See EXIT to exit a while-loop, even when expression is true.
Example
1
c = WHILE c < 10
PRINT c
1
c = c + WEND
' Output: 1 2 3 4 5 6 7 8 9
Code samples using WHILE
000 hello.bas
004 loops.bas
005 challenge.bas
006 arrays+.bas
100lines.bas
2048.bas
2048.bas
3d rotating cube with message.bas
3dtorus.bas
4tune.bas
A Rubens, Peter Paul Landscape.bas
agendus.bas
analog clock.bas
angel feather.bas
anomail.bas
Another center finder.bas
another look at trig functions.bas
aquarium v2.bas
B+B.bas
bairstow.bas
balls in 3d cube.bas
balls in 3d cube.bas
balls.bas
BAS_NOWv2.bas
base64.bas
bb2fork smurf.bas
betrayal: crows ii.bas
bezier's autograph book.bas
bezier_pen.bas
Language
AND
AS
BAND
BG
BOR
BYREF
CALL
CASE
CATCH
CONST
DECLARE
DEF
DO
ELIF
ELSE
ELSEIF
END
END TRY
ENDIF
EQV
EXIT
FALSE
FI
FOR
FUNC
GOSUB
GOTO
IF
IFF
IMP
IN
LABEL
LET
LIKE
LOCAL
LSHIFT
MDL
MOD
NAND
NEXT
NOR
NOT
ON
OR
REM
REPEAT
RETURN
RSHIFT
SELECT
STEP
STOP
SUB
THEN
THROW
TO
TRUE
TRY
UNTIL
USE
USG
USING
WEND
WHILE
XNOR
XOR
If there is insufficient information on this page and you wish learn more about WHILE,
please send an email to smallbasic@gmail.com. You can help to improve information about
WHILE by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.