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 #77 background imageLoading...
Page #77 background image
Log"
COMPARING
STRINGS
FOR SERVICE MANUALS
CONTACT:
MAURITRON
TECHNICAL
SERVICES
www,mauritron,co,uk
TEL:
01844·
3~1694
FAX:
01844
- 352554
IF "CAT" <
"DOG"
THEN
PRINT
"MEOW"
A great deal of computing
is
concerned with organising data so that
it
can be searched
qUickly. Sometimes
it
is
necessary to sort
it
in
to alphabetical order. The basis of various
sorting processes
is
the facility for comparing two strings to see which comes fllst
Because the letters
AB,C
...
are internally
coded
as
65,66,67.
..
It
is
natural to regard as
correct the following statements:
A
is
less than B
B
is
less than C
and because internal character by character comparison
is
automatically provided:
CAT
is
less than DOG
CAN
is
less than
CAT
You
can write, for example:
and the output would be:
MEOW
Similarly:
IF
"DOG"
>
"CAT"
THEN
PRINT
"WOOF"
would give the output:
WOOF
We
use the comparison symbols
of
mathematics for string comparisons,
All
the following
logical statements expressions are both permissible and
true,
"ALF" < "BEN"
IlK!T"
>
"BEN"
"KIT" <=
"LEN"
IIK!T"
>=
"KIT"
"PAT"
>=
"LEN"
"LEN"
<:
"LEN"
"PAT"
<>
"PET"
So
far,
comparisons based simply on internal codes make sense, but data
is
not always
conveniently restricted to upper case letters.
We
would
like,
for example:
Cat to be less than COT
and K2N to be less than
K27.N
A simple character by character comparison based on internal codes would not give
these results,
so
SuperBASIC behaves
in
a more intelligent
way,
The following program,
with suggested input and the output that
will
result, illustrates the rules for comparison
of strings,
100
REMark
comparisons
110
REPeat
camp
120
INPUT
"input
a
string"
!
fi
rst$
130
INPUT
"input
another
string"
!
secondS
140
IF
fi
rst$
<
secondS
THEN
PRINT
"Less"
150
IF
fi
rst$
>
secondS
THEN
PRINT
"Greater"
160
IF
first$
=
secondS
THEN
PRINT
"EquaL"
17.0
END
REPeat
camp
input
output
CAT
car Greater
CAT
CAT
Equal
PET
PETE
Less
K6
K7.
Less
K66
K7.
Greater
K12N
K6N Greater

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