EasyManuals Logo

Sinclair QL User Manual

Sinclair QL
422 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #38 background imageLoading...
Page #38 background image
IDENTIFIERS
AND
STRING
VARIABLES
RANDOM
CHARACTERS
SELF
TEST
ON
CHAPTER
4
22
Names of pigeon holes, such
as:
weekday$
word$
month$
phrase$
are called string identifiers. The dollar signs Imply that the pigeon holes are for character
strings. The dollar must always be
at
the end.
Pigeon holes of this kind are called string variables because they contain only character
strings which may vary
as
a program
runs.
The contents of such pigeon holes are called
values.
Thus words
like
'FIRST'
and 'OF'
may be values
of
string variables named weekday$ and +word$.
You
can
use
character codes
(see
Concept Reference
GUide)
to
generate random
letters.
The upper case letters A
to
Z have the codes 65
to
90.
The function CHR$ converts
these codes into
letters.
The following program
will
print a letter
B.
NEW.II
10
LET
Lettereode
;
66."
20
PRINT
CHR$(Lettereode)
..
'
RUN
..
,
The following program
will
generate trios
of
letters
A,
B,
or
C until
the
word CAB
is
spelled
accidentally.
NEW.II
10
REPeat
taxi
20
LET
first$
;
CHR$(RND(65
TO
67))
30
LET
seeond$;
CHR$(RND(65
TO
67))
40
LET
third$;
CHR$(RND(65
TO
67))
50
LET
word$
;
fi
rst$
&
seeond$
&
thi
rd$
60
PRINT 1
word$
1
70
IF
word$;
"CAB"
THEN
EXIT
taxi
80
END
REPeat
taxi
Random characters, like random numbers or random points are useful for learning
to
program.
You
can easily get interesting effects
for
program examples and exercises
Note the effect the 1 . . 1 have
on
the spacing
at
the output
You
can score a maximum of 10 points from the following test Check your score with
the answers
on
page
107.
1.
What
is
a character string?
2.
What
is
the usual abbreviation of the term, character string?
3.
What distinguishes the name of a string variable?
4.
How
do
some people pronounce a word such
as
wordS?
5.
What keyword
is
used
to
find the number
of
characters
in
a string?
6.
What symbol
is
used
to
join two strings?
7.
Spaces can be part of a string. How are the limits of a string defined?
8.
When a statement such
as:
LET meatS = "steak"
is
executed, are the quotes stored?
9.
What function will turn a suitable code number into a letter"
10. How can
you
generate random upper case
letters?
12/84

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals