EasyManua.ls Logo

Sinclair QL - Page 176

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...
RETurn
is
used
to
force a function
or
procedure
to
terminate and resume processing
at
the statement
after
the procedure
or
function
call.
When used
within
a function definition
theRETurn statement
is
used
to
return the function's
value.
RETurn
functions and
procedures
syntax:
example:
RETurn [expression]
100
PRINT
ack
(3,3)
110
DEFine
FuNction
ack(m,n)
120
IF
m=O
THEN
RETurn
n+1
130
IF
n=O
THEN
RETurn
ack
(m-1,ll
140 RETurn
ack(m-1,ack(m,n-1»
150
END
DEFine
ii.
10
LET
warning
flag
= 1
11
LET
error
number =
RND(O
TO
10J
12
warning
e-;ror
number
13 DEFine PROCedure
warning(n)
14
IF
warning
flag
THEN
15 PRINT "WARNING:";
16 SELect
ON
n
17
ON
n = 1
18
PRINT
"Microdrive
full"
19
ON
n =2
20
PRINT
"Data
space
full"
21
ON
n =
REMAINDER
22
PRINT
"Program
error
ll
23
END
SELect
24
ELSE
25
RETurn
26
END
IF
27
END
DEF
i ne
It
is
not compulsory
to
have
a RETurn
in
a procedure.
If
processing reaches the END comment
DEFine
of
a procedure then the procedure
will
return automatically.
RETurn by
Itself
is
used
to
return
from
a GOSUB.
RND
maths functions
PRINT RND(10
TO
20)
PRINT
RND(1
TO
6)
PRINT RND(10)
ii.
iii.
iv.
RND generates a random number. Up
to
two
parameters may be specified for RND.
If
no parameters
are
specified
then
RND returns a pseudo random floating pomt number
in
the exclusive range 0
to
1.
If
a single parameter
is
specified then RND returns
an
integer
in
the Inclusive range 0
to
the specified parameter
If
twc
parameters
are
specified
then RND returns
an
integer
in
the inclusive range specified by the two parameters.
syntax: RND (
[numenc_expresslon] [10 numenc_expressionj)
example: PRINT
RND
[ftoating
pOint
number between
o and
11
[integer between
10
and
201
(integer between 1 and
61
[integer between °and
101
FOR SERVICE MANUALS
CONTACT:
MAURITRON
TECHNICAL
SERVICES
www.mauritron.co.uk
TEL: 01844 . 351694
FAX:
01844
- 352554
12/84
49

Other manuals for Sinclair QL

Related product manuals