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 #142 background imageLoading...
Page #142 background image
DEFine FuNction defines a SuperBASIC function. The sequence of statements between
the DEFine function and the END DEFine constitute the function. The function definition
may also include a
list
of formal parameters which
will
supply data
for
the function. Both
the formal and
actual parameters must be enclosed
in
brackets.
If
the function requires
no parameters then there
is
no need
to
specify an empty set
of
brackets.
Formal parameters
take
their type and characteristics from the corresponding actual
parameters.
The type
of
data returned by the function
is
indicated
by
the type appended
to
the function identifier The type of the data returned
in
the RETURN statement must
match.
An
anS\\er
is
returned
from
a function by appending
an
expression
to
a
RETurn
statement
The type of the returned data
is
the same as type of this expression.
A function
is
activated by including
its
narne
in
a SuperBASIC expression.
Function calls
in
SuperBASIC can be recursive; that
is,
a function may
call
itself
directly
or indirectly via a sequence of other
calls.
syntax: forma/_parameters:= (expression *[, expression] *)
actua/_parameters:= (expression *
[,
expression] *)
DEFine
FuNction
END
DEFine
functions and
procedures
type: =
1$
1%
I
DEF FuNction identifier type [formal_parameters]
[LOCal identifier *
[,
Identifier] *]
statements
RETurn expression
END DEFine
RETurn can be
at
any position
Within
the procedure body. LOCal
statements must preceed the
first
executable statement
in
the function.
example:
10
DEFine
FuNction
mean(a,
b,
c)
20
LOCa
L
answer
30
LET
answer
=
(a
+ b +
c)/3
40
RETurn
answer
50
END
DEFine
60
PRINT
mean(1,2,3)
To
improve legibility of programs the name of the function can be appended
to
the END comment
DEFine statement.
However,
the name will not be checked by SuperBASIC.
12184

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