EasyManua.ls Logo

Commodore Plus 4 - Page 74

Commodore Plus 4
234 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...
10
FOR
X-
1
TO
15
sets
loop
for
15
times
20
PRINT
INT(5'RND(1))
-
1
_.
30
NEXT
X
selects
RaNDom
number
Type
RUN
and
press
RETURN
~~
An
effective
way
lo
use
this
formula
is
to
make
it
into
a
user
defined
fcj
function.
User
defined
functions
are
extremely
useful
in
mathematical
calculations,
and
extremely
easy
to
implement
using
your
Plus/4
User
defined
functions
allow
you
to
program
a formula,
and
then
let
your
Plus/4
plug
in
values
to
be
calculated
This
can
be used
for
many
dif
ferent
purposes.
Section
10
of
the
Encyclopedia
section
contains
a
listing
of
mathematical
function
derivatives
which
can
be
used
to
define
functions.
Here
is
a statement
utilizing
the
user
defined
function
for
generating
random
numbers
10DEFFNR(X)
=
INT<X"RND(l))
+
1
This
gives
us
random
numbers
in
the
range
from
1
to
X.
FNR
is
the
name
of
the
function
defined
by
this
statement.
■-—
EXAMPLE
using
a
defined
function:
10DEFFNR(X)
=
INT(X'RND(l))
+
1
20
DO
"—'
30
COLOR
1,
FNR(16),
5:
REM
PICK
A
COLOR
FROM
1
TO
16
40
PRINT
"THE
SEARCH GOES
ON"
50
LOOP
Using
the
defined
function
saves
memory
space
when
you use
the
function
more
than
once,
and
makes
your
programs
easier
to
read
and
understand.
67

Other manuals for Commodore Plus 4

Related product manuals