Chawter
10
I
BASIC
Kevwords
CHAIN
Statement
CHAIN
[MERGE]
pathnume
[,[,line]
[,ALL]
[,DELETE
line-line]]
Lets the current program load and execute another program
named
pathname.
Pathname
is
a
standard file specification as defined in Chapter
1.
It specifies the program you want
to
chain. The program must
have been previously saved in ASCII format. See SAVE.
Line
is the line number
or
variable containing a line number
where BASIC begins execution in the chained program.
Line
is
always preceded by a comma
(J.
If you plan
to
use the ALL
or
DELETE options and do not specify
a
line number, you must
specify
a
comma for
line.
This keeps BASIC from evaluating
ALL and DELETE
as
variables. If you omit
line,
BASIC begins
execution at the first program line
of
the chained program.
The ALL option tells BASIC
to
pass every variable in the cur-
rent program
to
the chained program. If you omit ALL, the cur-
rent program must contain
a
COMMON statement
to
pass
variables
to
the chained program.
If
chained programs chain
subsequent programs and pass variables, each new program
must contain either the ALL option
or
the COMMON statement.
The MERGE option overlays the lines
of
the chained program
with the current program. See the MERGE statement
to
under-
stand how BASIC overlays (merges) program lines.
The DELETE option deletes lines in the overlay
so
that you can
merge in a new overlay.
Ex
ample
s
CHAIN
"pr092"
loads
prog2,
chains it
to
the program currently in memory, and
begins executing it.
CHAIN
"subprog.
ba5",
,ALL
loads, chains and executes
subprog.bas.
The values
of
all the
variables in the current program are passed
to
subprog.bas.
108