Sinclair QL Beginner's Manual page 23

Hide thumbs Also See for QL:
Table of Contents

Advertisement

CHAPTER 4 – CHARACTERS AND STRINGS
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 letters, digits or other symbols which may or may not 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.
NAMES AND PIGEON HOLES FOR STRINGS
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:
you may choose to name two pigeon holes:
weekday$
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 weekday$ = "FIRST" 
an internal pigeon hole, named weekday$ will be set up with the value FIRST in it thus:
weekday$
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.
FIRST SECOND THIRD
JANUARY FEBRUARY MARCH
month$
FIRST
and

Advertisement

Table of Contents
loading

Table of Contents