Lesson 3


Loop'ing

To make a loop you do this
CLS
DO
Print hello
CLS
LOOP WHILE inkey$ ="" 'This will end when you hit any key {inkey$=""]

The 2nd CLS is there to clear the screen
thats the prety simple version of LOOP


Counter
a counter is exactly like a web page counter.

CLS
a = 1
DO
a = a +1 ' this adds 1 everytime it loops, so it goes - 1,2,3,4,5,6,etc
print a
LOOP UNTIL a = 30

This wil scroll 1 through 30 down the screen!
counters can be anything, like the following [or whatever you dream up! ]
counter = counter + 1
a = a +2
c = c + 1
b = b + 1
a = ((a +2)b)
But there are a few small rules, they must start!
Like you have to have a = 34 or b = 1 or whatever ABOVE the DO
if its in the loop and you set b = 3 then B WILL ALWAYS = 3 !!!!
This can be used in this way, BUT USUALY you dont want too!

Locate

Locate x,y ' I think thas it, if not experiment

the first PRINT statement starts at 1,1
Locate 1,1 ' is the top Left
Locate 1,23 ' or 1,24 experiment to get it

This is the most useful function...
If you want to make moving text this can be used!
My couse hasn't / wont teach this, we couldent do
3 problems without it, we had to skip then after they
were half done. [teacher dosent like Locate]

CLS ' This program has been tested!
a = 1
DO
a = a + 1
LOCATE 1, a
PRINT "Hello"
LOOP UNTIL a = 30

Run this one through.... it goes
HHHHHHHHHHHHHHHHHHHHello
Cause it added 1 so it was overwriting itself [and leaving H's] until it ended leavin "ello" on the end
Cange the a = a + 1 to a = a + 7
That will make it look a little more understandable!

1
Hosted by www.Geocities.ws