CHAPTER 2
The various loops
Get off the net if you still think it is happy hour(At least until you settle down). Here is your lesson.
;
The first of the many loops is the DO - LOOP loop. It runs eternally ,doing it's instructions ,stopping when you say so.It goes like this :
DO
x = x + 1
LOCATE 1,1 : PRINT x
LOOP
If you want it to stop when x reaches 20, type :
LOOP UNTIL x = 20
Many of the greatest programmers of all time in QBASIC used this loop alot.
;
Another loop, refered to as the FOR - NEXT loop was also used alot. It's syntax is :
FOR X =  0 TO 20 STEP 1
LOCATE; 1,1 : PRINT X
NEXT
In this loop, the computer counts from 0 to 20, STEP deciding how much is added every time. This is stored in a variable, say X.
The next loop is self-explanatory.
WHILE X < 270
x = x + 1
WEND
I don't really use it that much, since the other two are pretty much enough.
Here is a gem of a loop. It is called the Africa - Asia loop. It brings you on a trip from Asia to Africa and back. Have fun!
P.S: Once you understand, look at my nice logo below.
Hosted by www.Geocities.ws

1