Introducing Variables - Commodore VIC-20 User Manual

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

Advertisement

INTRODUCING VARIABLES
Many of the programs used in this book use variables to
simplify or strengthen the program.
Variables are very useful because they can be used to repre
sent numbers, formulas, graphic symbols, words, phrases —
even whoJe sentences. Examples of variable names are; X, AB,
S2, X$, ABS, S2$. The easiest way to explain the power of
variables is to tell you that these simple variables can each be
used to represent up to 255 characters!
There are two kinds of variables; numeric variables and string
variables. Numeric variables are used to store numbers (ac
tually, numeric values). String variables can be used to store
all types of characters (numbers, letters, graphics, cursor con
trols, color controls, etc.)*
BOX A
BOX AS
Variables are like storage cabinets inside the computer. To tell
the VIC that cabinet is for numbers or values, we must use a
speciaf name. Numeric variable names may be one or two
characters long and may be one letter, two letters, or a letter
and a number. Here are some examples of numeric variable
names:
AB
S2
C2
AA
ZX
String variable names may be one, two or three characters
long (including the $ sign), must always begin with a letter
from A to Z and have a dollar ($) sign at the end. Here are
some string variable examples:
X$
ABS
S2S
C2$
AA$
ZXS
86
(
c
(
I
I
I
{
(
c
c
(
<
(
c
<
I
I
I
I
<
c
I
I
c
c
c
c
c
c
c
c

Advertisement

Table of Contents
loading

Table of Contents