EasyManua.ls Logo

Laser 128 - Def Fn

Laser 128
255 pages
Print Icon
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...
3.8
DEF
FN
Purpose:
Format:
BASIC COMMANDS AND STATEMENTS
To
define
and
name
a
function
that
is
written
by
the
user.
DEF
FN
name
(real
variable)
expression.
Comments:
The
name is
exactly
the
same
as
a
variable
name.
A
user-defined
string
function
is
not
allowed:
Example:
The
real variable is
the
variable
that
will
be
used
when
the
function
is
evaluated.
The
expression
can
be
as
long
as
a
line
(239
characters
long).
If
you
need
to
program
functions
that
require
more
room
than
that,
you
should
implement
your
function
as
a
subroutine
.
10
GEE=
9.8
20
DEF
FN
DIS(T)=
GEE
* T
;..
2/2
30
INPUT
"Time?";T
40
PRINT
"Distance
is";FN
DIS(T)
This
would
calculate
the
distance
that
a
body
has
fallen
after
T
seconds,
using
the
function
DIS
which
is
derived
from
the
formula
s=l
/
2gt
2
,
where
s is
the
distance,
g
the
acceleration
due
to
gravity,
and
t
the
time
that
has
elapsed
since
the
object
was
dropped
from
a
stationary
position.
11-27

Table of Contents