Download Print this page

Radio Shack TRS-80 Owner's Manual page 125

Mini-disk operation disk operating system disk basic programming language
Hide thumbs Also See for TRS-80:

Advertisement

Examples
DEF
FNR(AtB)
=
A
+
INT((B
-
(A
-
1))
*
RNDC0))
This statement
defines
function
fnr which
returns
a
random number
between
integers
A
and B.
The
values
for
A
and
B
are
passed
when
the
function
is
"called,"
i.e.,
used
in
a statement
like:
Y
=
FNRtRl
>
R2)
If
ri
and
R2
have been
assigned
the
values 2
and
8, this
line
would
assign a
random number
between
2
and
8
to
y.
DEF
FNL$<>!)
=
STRING*
(X.
"-")
Defines function
fnl$
which
returns a
string
of
hyphens,
x
characters long.
The
value
for
x
is
passed
when
the function
is
called:
PRINT FNL*(3)
This
line
prints a string
of
30
hyphens.
Here's
an
example showing
deffn
used
for a
complex computation-^
in
double-precision.
DEF
FNX*(A#»
B*>
=
(A#
-
B*)
*
(A*
-
B#>
Defines function
fnx#
which
returns the
double-precision value of the square of
the difference
between
a#
and
B#. The
values
for
A#
and
B#
are
passed
when
the
function
is
called:
S#
=
FNX*(A»»
B«)
We
assume
that
values
for
a#
and
b#
were
assigned elsewhere
in
the
program.
Sample
Program
710 DEF FNV(T)
=
(1087
+
S0R(273
+
T))/1G,52
720 INPUT "AIR
TEMPERATURE
IN
DEGREES CELSIUS"
I
T
730 PRINT "THE SPEED OF SOUND
IN
AIR OF"
T
"DEGREES
CELSIUS
IS"
FNV(T)
"FEET PER SECOND,"
107

Advertisement

loading

This manual is also suitable for:

Model iii