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 #75 background imageLoading...
Page #75 background image
•
Handing
Text
You
can see that the answer
is
defined
by
the numbers 6
to
9 which Indicate where
it
is.
You
can abstract the answer
as
shown:
100
j
umb
Le$ ="APQOLLIONATSUZ"
110
LET
an$
=
jumbLe$(6
TO
9)
120
PRINT
an$
•
Now suppose that you wish
to
change the hidden animal into a bull.
You
can write
two
extra lines:
130
LET
jumble$(6
TO
9)
=
"BULL"
140
PRINT
jumbLe$
The output from the whole five-line program
is:
LION
APQOLBULLATSUZ
All string variables are initially empty, they have length
zero.
If
you
attempt
to
copy a
string into a string-slice which has insufficient length then the assignment may not be
recognised by SuperBASIC.
If
you
wish
to
copy a string into a string-slice then
it
IS
best
to
ensure the destination
string
is
long enough by padding
it
first
with spaces.
100
LET
subject$
="ENGLISH
MATHS
COMPUTING"
110
LET
student$
="
120
LET
student$(9
TO
13)
=
subject$(9
TO
13)
We
say that "BULL'
is
a slice of the string
':A,POOLBULLATSUZ':
The defining phrase:
(6
TO
9)
is
called a slicer.
It
has other
uses.
Notice how the same notation may be used on both
sides of the LET statement.
If
you want
to
refer
to
a single character
it
would be clumsy
to
write:
REPLACE
A
STRING
SLICE
•
jumbLe$(6
TO
6)
just
to
pick out the
"B"
(possibly as a clue)
so
you
can write instead :
jumbLe$(6)
to
refer
to
a single character.
Suppose you have a variable,
markS holding a record of examination marks. The slice
COERCION
giving the history mark may be extracted and scaled
up,
perhaps because the history
teacher has been too
strict
in
the marking. The following lines
will
extract the history mark:
100
LET
mark$
=
"625671"
110
LET
hi
st$
=
mark$(3
TO
4)
The problem now
is
that the value "56" of the variable, hist$
is
a string of characters
not numeric data.
If
you want
to
scale
it
up by multiplying
by,
say,
1.125,
the value
.of
hist$ must
be
converted
to
numeric data
first,
SuperBASIC
will
do
this conversion
automatically when
we
type:
120
LET
num
=
1.125
*
hist$
Line 120 converts the string "56"
to
the number 56 and multiplies
it
by
1.125
giving
63.
Now
we
should replace the old mark by the new mark but now the new mark
is
still
the number 63 and before
it
can be inserted back into the original string
it
must be
converted back
to
the string
'63:
Again SuperBASIC
will
convert the number automatically
when we type:
130
LET
mark$(3
TO
4)
=
num
140
PRINT
mark$
The output from the whole program
is:
626371
which shows the history mark increased
to
63.
12184
59

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