EasyManua.ls Logo

Sinclair QL - Page 180

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
Loading...
SELect
END
SELect
conditions
SElect
allows
vanous courses
of
action
to
be
taken
depending
on
the
value
of
a
vanable.
define:
selecL
vanable:
~
numeric_
variable
selecLitem:
~
I
expression
I
expression
TO
expression
selecL/lst:~
I selecLitem *[, selecLitem] *
Allows multiple actions
to
be
selected depending on
the
value
of
a
selecL
variabte.
long
The select variable
is
the
last
Item
on
the logical
line.
A senes
of
SuperBASIC
statements
follows,
which
IS
terminated by the next ON statement or by
the
END
SElect
statement.
If
the
select
Item
is
an
expression then a check
is
made within approximately 1 part
In
10-', otherwise
for
expression
TO
expression the range
is
tested exactly and
IS
inclusive. The ON REMAINDER statement
allows
a,
'catch-all" which
will
respond
if
no
other select conditions are
satisfied.
If
the select variable
is
used
In
the body
of
the
SElect
statement
then
It
must match
the
select variable given
in
the select header
The short form of the
SElect
statement
allows
simple single line selections
to
be made. short
A sequence
of
SuperBASIC statements
follows
on the same logical line
as
the
SElect
statement.
If
the condition defined
in
the select statement
is
satisfied then
the
sequence
of SuperBASIC statements
is
processed.
syntax:
SElect
ON selecLvariable
~
selecLlist:
statement
*[:
statement]
*
example: SELect
ON
test
data
=1
TO
10 :
PRINT
"Answer
within
range"
ii.
SELect
ON
answer
=
0.00001
TO
0.00005
PRINT
"Accuracy
OK"
iii.
SELect
ON
a = 1
TO
10:
PRINT
a I
"in
range"
The
short form
of
the
SElect
statement
allows
ranges
to
be tested more easily than comment
with
an
IF statement. Compare example
ii.
above
with
the corresponding IF
statement.
syntax:
example:
SElect
ON
selecL
variable
*[[ON
selecLvariable] selecLlist
statements]
*
[ON selecLvanable]
~
REMAINDER
statements
END
SElect
100
LET
error
number =
RND(1
TO
10)
110 SELect
ON
error
number
120
ON
error
number =1
130
PRINTIiOivide
by
zero"
140
LET
error
number = 0
150
ON
error
number =2
160
PRINTI'iFi
Le
not
found"
170
LET
error
number = 0
180
ON
error
number = 3
TO
5
190
PRINT"Microdrive
fi
le
not
found"
200
LET
error
number =0
210
ON
error
number =
REMAINDER
220
PRINT"'"'i"iUnknown
error"
230
END
SELect
12/84
53

Other manuals for Sinclair QL

Related product manuals