•
•
Teachers sometimes
wish
to
assess the reading ability needed
for
particular books or
classroom materials.
Various
tests
are used and some
of
these compute the average
lengths
of
words and sentences.
We
will
introduce ideas about handling words or
character strings
by
examining simple approaches
to
finding average word lengths.
We
are
talking about sequences
of
leners,
digits or other symbols which
mayor
may
nof be words. That
is
why the term character string' has been Invented.
It
is
usually
abbreviated
to
string. Strings
are
handled
in
ways
similar
to
number handling
but,
of
course,
we
do
not
do
the
same
operations
on
them.
We
do
not
multiply or subtract
strings.
We
join them, separate them, search them and generally manipulate them
as
we
need.
You
can create pigeon holes
for
strings.
You
can put character strings into pigeon holes
and use the Information
Just
as
you do
with
numbers.
If
you
Intend
to
store (not
all
at
once) words such
as:
FIRST SECOND THIRD
and
JANUARY FEBRUARY MARCH
you
may choose
to
name
two
pigeon holes:
CHAPTER
4
CHARACTERS
AND
STRINGS
NAMES
AND
PIGEON
HOLES
FOR
STRINGS
weekday$ D
month$D
•
Notice the dollar sign. Pigeon holes
for
strings are internally different
from
those for
numbers and SuperBASIC needs
to
know which
is
which.
All
names
of
string pigeon
holes must end
with
$.
OtherWise
the rules for choosing names
are
the
same
as
the
rules
for
the names
of
numeric pigeon
holes.
You
may pronounce:
weekday$
as
weekdaydollar
month$
as
monthdollar
The LET statement works
in
the same
way
as
for numbers.
If
you
type:
LET
weekdayS
=
"FIRST"
"II
an
internal pigeon
hole,
named weekday$,
will
be
set
up with the
value
FIRST
in
it
thus:
weekdaY$1
FIRST I
The
quote marks
are
not
stored.
They
are
used
in
the LET statement
to
make
it
absolutely
clear what
is
to
be
stored
in
the pigeon
hole.
You
can check
by
typing:
PRINT
weekday$
..
"
and the screen should display what
is
in
the pigeon hole:
FIRST
You
can use a pair
of
apostrophes instead
of
a pair
of
quote
marks.
12/84
19