Commodore VIC-20 User Manual page 53

Hide thumbs Also See for VIC-20:
Table of Contents

Advertisement

The next line is:
2 N = INT(RND(1)'8)+ 1
This line generates a random positive whole number from
one through eight and puts the number into "N". "N" is the
place in the VIC's memory that can be used to store
numbers. The VIC knows that "N" is a place to store
numbers since there is no dollar sign {$) at the end of
the name.
In line one, the location used to store the color controls was
called AS, and it has a dollar sign on the end. The VIC knows
that locations whose names end with a dollar sign are to be
used to store messages or strings of characters.
For more information on how G] [HI E and II § [H work
together to generate random numbers, look at Chapter
Seven in this book. For now, just be aware that this line is
producing numbers from one through eight. See the number
eight on the right side of the equal sign? That number
controls how many random numbers are being generated. If
you were to change the eight to a six, then any number from
one through six would be produced.
Hmmm . . . moving right along now:
3 B$ = MID$(A$,N,1)
This line creates a new box called B$, and puts one color
control character into it. AS contains all eight color control
characters. "N" is a random number from one through
eight. What does MIDS do? It picks out one color control
character from A$ at the "N"th position in the string. This
character is put into B$. Yes, "Virginia", now we have three
little boxes inside the VIC, one called AS, one called "N"
and one called B$. Each time the VIC gets to line two, it is
given a new value for "N". This determines which color MID$
picks and puts into B$.
E J
43

Advertisement

Table of Contents
loading

Table of Contents