EasyManua.ls Logo

IBM 5100

IBM 5100
187 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...
66
After
control
is
passed
to
a DEF statement
without
reference
to
the function, con-
trol
goes
to
the first executable statement following the function
definition-
following the DEF statement
for
single-line functions, and following the FNEND
statement
for
multiline functions.
The last executable statement preceding the FNEND statement should
be
a
RETURN,
STOP,
CHAIN,
or unconditional GOTO
to
prevent control from
passing
to
the FNEND statement.
If
a function definition alters the
value
of
a variable that
is
referenced in the
same
statement that calls the function, unpredictable results
may
occur.
Example
The following examples illustrate the execution
of
DEF statements:
10
DEF
FNA
(X) =
Xt3/2
20 Y = 10
30
Z=
FNA(Y)
After
execution
of
statement 30, the variable Z will
have
the integer value 500.
In the next example, the variable R
will
have
the integer value 72 after execution
of
statement 80.
When
statement 80
is
executed, the current value
of
Y,
which
is
2,
is
substituted
for
each
occurrence
of
the dummy variable X in the arithmetic expres-
sion
of
statement 100. Since the function FNC, defined in statement 100,
uses
the
function FNB in
its.
definition, the value 2
is
substituted
for
each
occurrence
of
X in
the arithmetic expression
of
statement 90. The resulting value, 47,
is
then substituted
for
the function reference FNB(X) in statement 100. The current value
of
Y, which
is
2,
is
then
added
to
47, and the resulting value
of
49
is
substituted
for
the function
reference FNC(Y) in statement 80. This
value
is
added
to
23,
and
the resulting
value
of
72
is
assigned
to
the variable
R.
70
LETY
= 2
80 LET R
= FNC(Y) + 23
90 DEF FNB(X)
=
5*X**2+27
100 DEF FNC(X) .. FNB(X) + X
The following example
shows
a multiline function definition.
When
these
state-
ments
are
executed both C and 0
will
have
a value
of
7.
10A
= 5
20
B=
2
30 DEF
FNA
(X,Y)
40 IF X>O GOTO 60
50
RETURN
X-V
60 RETURN
X+Y
70 FNEND
80 C
=
FNA
(A,B)
90 0
=
FNA
(A,B)
/

Table of Contents

Other manuals for IBM 5100

Related product manuals