and string variable names.
A$
M$
MN$
MI$
ZX$
F6$
Chapter
3:
Programming the
VIC
20
Computer 67
Variable names can have more than two alphanumeric characters, but
only the first two characters count. Therefore BANANA and BANDAGE
are interpreted
as
the same name, since both begin with
BA.
VIC BASIC
allows variable names to have up to
86
characters, but such large names are
impractical.
Four
to eight characters
is
a more realistic limit; long names
may actually make it harder to read your program. The names below
illustrate the way VIC BASIC "sees" long variable names.
MAGIC$ interpreted
as
MA$
Nl23456789
interpreted
as
NI
MMM$
interpreted
as
MM$
ABCDEF%
interpreted as AB%
CALENDAR
interpreted
as
CA
If you use variable names with more than two characters, keep the
following points in mind:
I. Only the first two characters plus the identifier symbol
($
or
%) are
significant. Do not use extended names like LOOPI and LOOP2;
these are interpreted as the same variable: LO.
2.
VIC BASIC has a number of reserved words which have special
meaning within a BASIC statement. Reserved words include
BASIC statements, such as PRINT, and others which
we
will
discuss later. No variable name can contain a reserved word
embedded anywhere in the name. For example, you cannot
use
PRINTER
as a variable name, because BASIC would see it as
"PRINT
ER."
This problem usually shows up as a syntax error in a
line
that
looks correct. Table 3-4
is
a complete list of reserved
words.
3.
Additional characters use up memory space that you might need in
longer programs. On the other hand, longer variable names make
programs
easier
to
read.
PAR
TNO,
for
example, is more
meaningful than PA as a variable name describing part numbers in
an inventory program.