(
(
;f
(
CHARACTER
DATA
Character data
in
BASIC
is
data
without
a numeric value. Like arithmetic data, char-
acter data can be in
the
form
of
constants or variables.
Character Constants
A character constant
is
a string
of
characters enclosed
in
a pair
of
single
quotation
marks. Any letter, digit,
or
special character can be included
in
a character constant.
An apostrophe, however, must be indicated by using
two
single
quotation
marks.
For example,
'IT'S'
represents IT'S. The following are
all
valid character constants:
'YES'
'THE SQUARE OF X IS'
'12345'
'A
B'
The length of a character constant, when displayed or printed,
is
the
number
of
characters it contains, including blanks,
but
excluding
the
delimiting
quotation
marks.
Each pair
of
single quotation marks used
to
represent an apostrophe
is
counted
as
one character. The maximum number
of
characters
in
a single character constant
is
limited only by
the
maximum number
of
characters on an
input
line, which
is
64
(including quotation marks).
Character Variables
A character variable
is
a named item
of
character data whose value
is
subject
to
change during execution
of
the
program. Character variables are named by a single
letter
of
the
extended alphabet (A-Z, @,
#,
and $), followed
by
the
currency symbol
($). Examples of character variables are A$,
#$,
and $$.
When
the
program
is
executed,
the
initial value
of
character variables
is
set
to
18
blank characters. The only exception
is
that
variables assigned
to
the
common
storage area are
not
initialized (see USE, Chapter
4)
for a program
that
is
chained
to
(see CHAIN, Chapter 4). These variables are initialized
to
blanks by a LOAD
or
RUN
command (see Chapter 2).
When character constants are assigned
to
character variables,
the
values
of
the
con-
stants are adjusted
to
a length
of
18. Longer constants are
truncated
on
the
right, and
shorter constants are left-justified and padded with blanks
to
the
right.
ARRAYS
An array
is
a collection
of
data items (elements)
that
is
referred
to
by a single name.
Only data items
of
the
same
type
(numeric
or
character) can be grouped together
to
form an array.
45