CHAPTER
2
INSTRUCTING
THE
COMPUTER
•
Computers need
to
store
data such as numbers. The storage can be imagined
as
pigeon
holes.
D D
D
Though
you
cannot see them, you
do
need
to
give names
to
particular pigeon holes.
Suppose you want
to
do
the tollowing simple calculation.
A
dog
breeder has 9 dogs
to
feed for 28 days, each
at
the
rate
of one
tin
of 'Beefo
per
day.
Make the computer print (display on the screen) the required number of tins
One way of solving
thiS
problem would require three pigeon holes
for:
oom~ct~
•
number of
days
total
number of
tins
SuperBASIC
allows
you
to
choose sensible names
for
pigeon holes and you may choose
as shown:
dogs
D days D tins D
6
You
can make the computer set
up
a pigeon hole, name
it,
and store a number
in
it
with a single instruction or statement such'
as:
LET
dogs
=9.-,
This will
set
up
an internal pigeon hole, named dogs, and place
in
it
the number 9 thus:
dogs
D
The word LET has a special meaning
to
SuperBASIG
It
is
called a keyword. SuperBASIC
has many other keywords which you will see
later.
You
must be careful about the space
after LET and other keywords. Because SuperBASIC allows you
to
choose pigeon hole
names with great freedom
LETdogs would
be
a valid pigeon hole name.
The LET keyword
is
optional
in
SuperBASIC and because of this statements
like:
LETdogs
=9
..
"
are valid. This would refer
to
a pigeon hole called LETdogs.
Just
as,
in
English,
names,
numbers and keywords should be separated from each other
by spaces
if
they are not separated by special characters.
Even
if
it
were
not
necessary,
a program line without proper spacing
is
bad
st>"e.
Machines
with small memory
size
may force programmers into
it,
but that
is
not a problem with
the OL.
You
can check that a pigeon hole exists internally by typing:
PRINT
dogs.-,
The screen should display what
IS
in
the pigeon hole:
9
Again, be careful to put a space after PRINT.
12/84
•
•