CHAIN file$
Clear the current program from memory and run the new program (‘file$’) starting with the first line.
Unlike the RUN command this command retains the current state of the program (ie, the value of variables, open files, loaded fonts, open COM ports, etc). The only exception is that any open interrupts will be automatically closed.
One program can CHAIN to another which can then chain to another (or back to the original) an unlimited number of times.
The CHAIN command automatically runs the RESTORE command (reset the DATA pointer) following the successful chain to a new program.
As long as a program can be broken down into modules this command allows programs of almost unlimited size to be run, even with limited memory. Communication between the modules can be accomplished by assigning values to one or more variables which then can be examined by the new chained program.
Note that another way of squeezing a large program into limited memory is to use the LIBRARY command.
See also:
LOAD
NEW
RUN
SAVE
WATCHDOG
Leave a Reply