LOOP[UNTIL boolean argument ' WHILE boolean argument]
(An example of a boolean argument is A=I or H> =57 )
Performs the statements between the DO statement and the LOOP
statement. II no UNTIL or WHILE modifies either the DO or the LOOP
statement, execution of the intervening statements continues
indefinitely. If an EXIT statement is encountered In the body of a DO
loop, execution is transferred to the first statement following the LOOP
statement DO loops may be nested. following the rules defined for
FOR-NEXT loops.
If the UNTIL parameter is used, the program continues looping until the
boolean argument is satisfied (becomes TRUE). The WHILE parameter
Is basically the opposite of the UNTIL parameter. the program continues
looping as long as the boolean argument is TRUE.
EXAMPLE
DO UNTIL X =0 OR X .=1
LOOP
DO WHILE AS="":GET AS:LOOP
DRAW
DRAW [colour source #11. al . bl I
a2. b2.11 . .
With this command you can draw individual dots, lines, and shapes
You supply colour source (0-3), starting (al , b1) and ending points (a2
b2).
EXAMPLES
a dot'
DRAW I. 100, 50 — no endpoint specified. defaults to
al ,b1 value for a2.b2 to create a dot
Ilnes:
DRAW , 10,10, TO 100,60
DRAW TO 25,30
a shape:
DRAW , 10,10 TO 10,60 TO 100,60 TO 10,10
END
END
When the program executes an END statement, the program stops
RUNning immediately. You may use the CONT command to re-start
the program at the statement following the END statement
FOR . . . TO .
STEP
FOR variable = start value TO end value [STEP Increment!
This statement works with the NEXT statement to set up a section of
the program that repeats for a set number of times. You may lust want
your computer to count up to a large number so the program pauses for
a few seconds, in case you need something counted, or something
must be done a certain number of times (such as printing).
The loop variable is the variable that Is added to or subtracted from
during the FOR/NEXT loop. The start value and the end value are the
beginning and ending counts for the loop variable.
The logic of the FOR statement is as follows. First, the loop variable Is
set to tne start value. When the program reaches a line with the
command NEXT, it adds the STEP increment (default = 1) to the value
of the loop variable and checks to see if it is higher than the end of loop
value. If it is not higher, the next line executed is the statement
immediately following the FOR statement. If the loop variable is larger
than the end of loop number, then the next statement executed Is the
one following the NEXT statement A STEP value can be positive or
negative. See also the NEXT statement.
EXAMPLE
10 FOR L = 1 TO 20
20 PRINT L
30 NEXT L
40 PRINT "BLACKJACK , L = "L
116
117
Need help?
Do you have a question about the Commodore 16 and is the answer not in the manual?
Questions and answers