A New Counter
FOR...NEXT is a loop like DO...LOOP, but a FOR...NEXT
loop has its own counter built in. Try this:
FOR I = 1 TO 10
Much better than our last counter. This one stops on
its own after counting to 10.
A Color Chart
Here's a color chart program using a FOR...NEXT loop.
FOR I = 1 TO 15
COLOR I, 0
PRINT I; "*** COLOR ***"
FOR...NEXT can also do "step counting". Try this:
FOR I = 2 TO 20 STEP 2
That will count by 2's from 2 to 20. STEP tells
QBASIC what to count by. Try changing it to count by
10's from 10 to 100.
FOR...NEXT can also count backwards if you use a
negative STEP value:
FOR I = 10 TO 1 STEP -1
PRINT "BLAST OFF!"
"SLEEP 1" tells QBASIC to wait for
one second, then continue.