EasyManua.ls Logo

Commodore PET - Page 149

Commodore PET
447 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...
ON
...
GOSUB
The
ON
...
GOSUB statement provides conditional subroutine calls
to
one
of several subroutines in a program. depending on the current value of the
specified index.
Format:
ON
index GOSUB
linel.line2
.....
Iine
n
where:
index
is
a constant. variable. or expression
that
must
be
in the range
0<index::;.255.
Iinei
is
one or more line numbers specifying the
beginning lines of subroutines.
ON
...
GOSUB
has
the same format
as
ON
...
GOTO.
and the statement
is
evaluated in the same way
(see
ON
...
GOTO).
For
index=l.
the subroutine beginning at
linel
is
called.
When
that
subroutine
is
completed
(a
RETURN
statement). the program continues
with
the
statement
following
the
ON
GOSUB. If index=2. the subroutine beginning
with
line2
is
called, etc. The
ON
GOSUB statement should
be
used only
to
cali
subroutines
that
retum control via
RETURN
statements to the statement
following
the
ON
GOSUB.
ON
GOSUB
is
normally executed in program mode.
It
may
be
executed in
immediate mode
as
long
as
there are corresponding line numbers in the current
stored program
that
may
be
branched to.
Example:
10
ON
A GOSUB 100.200.300
ON
...
GOTO
The
ON
...
GOTO
statement provides conditional branching to one of
several points in a program. depending on the current value of the specified index.
Format:
ON
index
GOTO
linel.line2
.....
Iine
n
where:
736
index
Iinei
is
a constant. variable. or expression
that
must
be
in the range
0<index::;.255.
is
one or more line numbers.

Table of Contents

Related product manuals