example:
DEFine
PROCedure
END
DEFine
functions and
procedures
DEFine PROCedure defines a SuperBASIC procedure. The sequence
of
stafements
between the DEFine PROCedure statement and
the
END DEFine statement constitutes
the procedure. The procedure definition may also include a
list
of formal parameters
which
will
supply data
for
the procedure. The formal parameters must be enclosed
in
brackets for the procedure definition, but the brackets are not necessary when the
procedure
IS
called.
If
the procedure requires no parameters then there
is
no need
to
Include an empty
set
of brackets
In
the procedure definition.
Formal parameters
take
their type and characteristics from the corresponding actual
parameters.
Variables may be defined
to
be LOCal
to
a procedure. Local variables have no effect
on similarly named variables outside the procedure.
If
required, local arrays should be
dimensioned within the LOCal statement.
The procedure
IS
called by entering
its
name
as
the
first
Item
In
a Super
BASIC
statement
together with a
list
of actual parameters Procedure calls
In
SuperBASIC are recursive;
that
is,
a procedure may
call
itself directly or Indirectly via a sequence of other calls.
It
is
possible
to
regard a procedure definition
as
a command definition
,n
SuperBASIC;
many of the
system
commands are themselves defined
as
procedures.
syntax:
formal_parameters: = (expression *
[,
expression] *)
actual_parameters:=
expression *
[,
expression] *
DEFine PROCedure identifier [formal_parameters]
[LOCal identifier *
[,
identifier] *J
statements
[RETurn]
END DEFine
RETURN can appear
at
any position within the procedure body.
If
present
the LOCal statement must be before the
first
executable statement
in
the
procedure. The END DEFine statement
Will
act
as
an
automatic return.
100
DEFine
PROCedure
start
screen
110
WINDOW
100,100,10,10
120
PAPER 7 : INK
0:
CLS
130
BORDER
4,255
140
PRINT
"Hello
Everybody"
150
END
DEFine
160
start
screen
ii.
100
DEFine
PROCedure
slow
scroll(scroll
limit)
110
LOCa l
count
120
FOR
count
= 1
TO
scroll
limit
130
SCROLL 2
140
END
FOR
count
150
END
DEFine
160
slow
scroll
20
•
•
•
comment
To
improve legibility of programs the name of the procedure can be appended
to
the
END DEFine statement.
However,
the name
Will
not be checked
by
SuperBASIC.
16
12184