EasyManua.ls Logo

Sharp MZ-800 - Page 76

Sharp MZ-800
221 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
Format
ON
<numeric
expression>
GOSUB
{
<line
number
>[,<line
number
>]
...
<label>
[,<label>]
...
Abbreviated
Format
ON~GOS.
Explanation
The
ON
~GOSUB
statement
branches
program
execution
to
the
subroutine
indi-
cated
by
one
of
the
line
numbers
following
GOSUB,
depending
on
the
value
of
<numeric
expression>.
The
operation
of
this
statement
is
basically
the
same
as
with
the
ON~GOTO
statement,
but
all
branches
are
made
to
subroutines.
Upon
return
from
the
subroutine,
execution
resumes
with
the
first
executable
statement
following
the
ON~
GOSUB
statement
which
made
the
call.
Example
Let
us
try
using
the
ON~GOSUB
statement
in
a
scheduling
program.
The
most
important
point
to
note
in
the
following
program
is
that,
a
subroutine
call
is
made
at
line
180,
even
though
line
180
itself
is
part
of
a
subroutine
(from
line
170
to
190)
which
in
turn
is
called
by
line
90,
Subroutines
can
be
nested
to
many
levels
in
this
manner.
10
A$="
ENGL
"':
BS=""
MATH
":
C$=""
FREN
”’
20
D$="
SCI
":
E$=""
MUS)
":
F$="
GYM
"
30
G$="
HIST
":
H$=""
ART
“':
1$="'
GEOG
"
40
J$=""
BUS
=“:
K$=""
H
RM
":
CLS
50
INPUT
‘‘WHAT
DAY?"';X$
60
FOR
Z=1
TO
7:Y$=MID$("SUNMONTUEWEDTHUFRISAT”,
1
+3#(Z—1),3):
IF
Y$=X$
THEN
X=Z
70
NEXT
Z
80
FOR
Y=0
TO
4:
PRINT
TAB(5+6*Y);Y
+1;
90
NEXT
Y:
PRINT
100
ON
X
GOSUB
180,120,130,140,
150,160,170
110
PRINT:
GOTO
50
120
PRINT
‘MON
‘';A$;B$;D$;G$;K$:RETURN
130
PRINT
“*
TUE
$;E$;H$;H$;D$:RETURN
140
PRINT
"WED
$;C$;1$;A$;F$:RETURN
150
PRINT
"THU
'';B$;D$;F$;G$;E$:RETURN
160
PRINT
“FRI;
‘AS;
D$;1$;C$;C$:RETURN
170
PRINT
“‘SAT
‘’;B$;G$;D$;K$:RETURN
180
FOR
Y=1
TO
6
190
ON
Y
GOSUB
120,130,140,150,160,170
200
PRINT:NEXT
Y
210
RETURN
6-19

Other manuals for Sharp MZ-800

Related product manuals