So far, we've only let the user fill in our variables.
We can fill in variables on our own inside our programs too.
Like this:
CLS A = 1 B = 2 A$ = "Hello" PRINT A PRINT B PRINT A$
"A = 1" places the value 1 in the variable A. "B = 2"
places the value 2 in the variable B. A$ = "Hello" places
the string "Hello" in the variable A$. You get the picture.
Then the program prints them out to prove to you that they
are there.
See if you can figure out what this rather clever
program will do. Then type it in and run it to see if you
were right.
CLS Count = 1 DO PRINT Count Count = Count + 1 LOOP
Did you get it right? Did the output go by
way too fast? You'll have to press Break to stop
it. Then take a closer look and see if you can see
what's going on.
That program is what is called a "counter". It
counts 1, 2, 3, 4... until it is stopped.
Source: http://jpsor.ucoz.com |