On Gosub Is The Use Of A Subroutine Group - Sharp MZ-80A Owner's Manual

Hide thumbs Also See for MZ-80A:
Table of Contents

Advertisement

55
| ON
.....
GOSUB
is the
Use
of
a
Subroutine Group
The ON
.....
GOSUB
statement
is
very
similar
in function
to
the ON
.....
GOTO
statement.
Now,
let's consider the program for a time table
to
check
your
progress. Most important in the following program
is that subroutines are
called
at
line number
180,
despite the jump made
at
line number 90
to
line number 170 through
190
of subroutines.
Thus,
the GOSUB and ON
.....
GOSUB
statement
can be used in
a
convenient, multiple manner.
10 AS =
"FRENCH "
:
BS
=
"MATHEMATICS" :
CS
=
"ENGLISH"
20
DS = "SCIENCE "
: E$
= "MUSIC
" :
FS = "ATHLETICS"
30
GS
= "SOCIAL STUDIES"
:
HS = "ART
" :
IS = "TECHNOLOGY"
40
JS
=
"RELIGION
KS = "ECONOMICS"
50
PRINT
"WHAT
DAY OF THE WEEK
?
"
55 PRINT
"(1
-
MON, 2
-
TUE,
3
- WED.
4
-
THU, 5
-
FRI, 0
-
ALL)"
60 INPUT XS X = ASC
(X$)
-
47
70 FOR Y = 0 TO 3
: PRINT TAB
(3
+
8
*
Y)
;
Y
+
1 ;
80
NEXT Y
:
PRINT
90 ON X GOSUB
170, 110,
120.
130, 140, 150
100 PRINT: GOTO 50
1
10 PRINT "MON
:
" ;
"AS
;
CS
;
DS
;
BS
:
RETURN
1 20
PRINT "TUE
:
" ; HS
;
HS
;
ES
;
BS
:
RETURN
1
30
PRINT "WED
: " ;
AS
;
CS
;
JS
;
KS
:
RETURN
140
PRINT "THU
:
"
;
DS: AS : ES
;
FS
:
RETURN
1 50
PRINT "FRI
: "
;
AS
;
DS
;
IS
;
GS
:
RETURN
170 FOR Y=
1
TO 5
180 ON Y GOSUB 110,
120.
130, 140, 150
190
PRINT: NEXT Y
200 RETURN

Advertisement

Table of Contents
loading

Table of Contents