EasyManua.ls Logo

HP HP-67 - Routine-Subroutine Usage

HP HP-67
364 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...
204
Subroutines
Routine-Subroutine
Usage
Subroutines
give
you
extreme
versatility
in
programming.
A
sub-
routine
can
contain
a loop,
or
it
can
be
executed
as
part
of
a
loop.
Another
common
and
space-saving
trick
is
to
use
the
same
routine
both
as
a
subroutine
and
as
part
of
the
main
program.
Example:
The
program below
simu-
lates
the
throwing
of
a
pair
of
dice,
pausing
to
display
first
the
value
of
one
die
(an
integer
from
1
to 6)
and
then
pausing
to
display
the
value
of
the
second
die
(another
integer
from
1
to
6).
Finally
the
values
of
the
two
dice
are
added
together
to
give
the
total
value.
The
‘‘heart’”
of
the
program
is
a
random
number
generator
(actually
a
pseudo
random
number
generator)
that
is
executed
first
as
a
sub-
routine
and
then
as
part
of
the
main
program.
When
you
key
in
a
first
number,
called
a
‘‘seed’’,
and
press
3,
the
digit
for
the
first
die
is
generated
and
displayed
using
the
f#
(€]
routine
as
a subroutine.
Then
the
digit
for
the
second
die
is
generated
using
the
same
routine
as
part
of
the
main
program.
To
key
in
the
program:
Slide
the
Program
Mode
switch
wrem
[[[[Illrun
to
W/PRGM.
Press
Display
fooo
(00157
31
—s5-00]
(€)
executed
first
as
subroutine.
oes
%“>a§
o
STO
a
]
©

Table of Contents

Other manuals for HP HP-67

Related product manuals