BASIC
However,
you
may assign different
attributes
to
variables
by
using
definition
statements
at
the beginning of your
program:
DEFINT—
Defines variables as integer
DEFDBL
—Defines variables as double-precision
DEFSTR
—
Defines variables as string
DEFSNG
—
Defines variables as
single-precision. (Since BASIC classifies all
variables as single-precision initially anyway, you
would only need
to
use
DEFSNG
if one of the other DEF statements
were used.
For
example:
DEFSTR L
makes
BASIC classify all
variables which start with L
as string variables. After this
statement, the variables:
L LP LAST
can all hold string values only.
Type Declaration Tags
As with constants,
you
can always override the type
of
a
variable name
by
adding
a
type declaration
tag
at the end. There
are four type
declaration tags for variables:
Integer
Single-precision
Double-precision n
String
For example:
1% FT%
NUM%
COUNTER%
are all integer
variables,
regardless
of what attributes
have been assigned
to
the
letters I, F, N and C.
T! RY! QUAN!
PERCENT!
are all
single-precision variables, regardless of
what attributes have been assigned
to
the letters
T, R,
Q
and
P.
X# RR# PREV#
LSTNUM#
are
all double-precision variables, regardless
of what attributes have been assigned
to
the letters
x, R, P
and
L.
107