Chapter
10
I
BASIC Keywords
Sample
Programs
MERGE provides
a
convenient means of putting program mod-
ules together. For example, an often-used set
of
BASIC subrou-
tines can accompany a variety
of
programs with this command.
Suppose the following program
is
in memory:
80 REM MAIN PROGRAM
90 REM LINE NUMBER RESERVED FOR SUBROUTINE
HOOK
100 REM PROGRAM LINE
110 REM PROGRAM LINE
120 REM PROGRAM LINE
130 END
And suppose the following subroutine,
sub.txt,
is stored on disk
in ASCII format:
90 GOSUB 1000 'SUBROUTINE
HOOK
1000 REM BEGINNING OF SUBROUTINE
1010 REM SUBROUTINE LINE
1020 REM SUBROUTINE LINE
1030 REM SUBROUTINE LINE
1040 RETURN
You can MERGE the subroutine with the main program with:
MERGE
"5ub.
txt"
The new program in memory is:
80 REM
90 GOSUB 1000
100 REM
110 REM
120 REM
130 END
1000 REM
1010 REM
1020 REM
1030 REM
1040 RETURN
MAIN PROGRAM
'SUBROUTINE
HOOK
PROGRAM LINE
PROGRAM LINE
PROGRAM LINE
BEGINNING
OF
SUBROUTINE
SUBROUTINE LINE
SUBROUTINE LINE
SUBROUTINE LINE
217