BASIC
Ways of
Representing Data
BASIC recognizes data
in two forms —either directly,
as constants, or
by
reference
to
a
memory location, as
variables.
Constants
All data is input
into
a
program as
"constants"
—
values which are not subject to
change. For
example, the statement:
PRINT
"1
PLUS
1 EQUALS"; 2
contains one string
constant,
1PLUS1 EQUALS
and one numeric constant
In these examples, the constants
"input" to the PRINT statement.
They tell
PRINT
what data
to print on the Display
.
These are more
examples of constants:
3.14159
"L.O.SMITH"
1.775E
+
3
"0123456789ABCDEF"
"NAME TITLE" -123.45E-8
57
"AGE"
Variables
A variable
is
a
place in memory
—
a
sort of box
or pigeonhole —where data is
stored. Unlike a
constant,
a
variable's value can change.
This allows you to write
programs dealing with changing
quantities. For example,
in the statement:
A$
=
"OCCUPATION"
The variable A$
now contains the data OCCUPATION.
However, if this statement
appeared later in the program:
A$
=
"FINANCE"
The variable A$
would no longer contain OCCUPATION. It
would now contain the
data
FINANCE.
99