English
Language : 

NSB8 Datasheet, PDF (117/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
ITALIAN TECHNOLOGY
grifo®
CHAINING (AUTOMATIC PROGRAM SEQUENCING)
Through use of the CHAIN statement (discussed in detail under statement CHAIN), one program
may cause another to be automatically loaded and run, eliminating the need for the user to initiate
and supervise such activities from the console. Thus, a sequence of programs may operate virtually
unattended for long periods (uless, of course, one or more of the programs requires interactive data
input or various diskettes need to be swapped in and out of the drives). There are two situations when
chaining is most effectively used:
1) You desire to use several separate programa as a complete software system where each program
can automatically transfer to another program whenever necessary.
2) A program may be too large to fit into the available program/data area, but can be broken up into
separate, self contained modules which CHAIN bettween themselves to accomplish the desired
task.
COMMUNICATION BETWEEN CHAINED PROGRAMS
All variables are cleared by a successful CHAIN operation, so variables which are shared by one or
moremodules must be restored at the start of each module.
It is frequently necessary for a chained program to accept information from the module which
precedes it or pass data to the program to wich it will chain.
Several methods may be used to accomplish program to program communication. The two most
commonly used ones are described below.
A data file may be shared between two programs, and thus provide for communication between them.
This file might be a common data base (of invoices, customer name, calendar items, switchboard
messages, products informations, parameters, etc.) in which case each separate module would infer
the action it should take by examining the current state of the file. Programs may use files to
communicate in a more direct fashion if actual variables are shared between them: program A would
write the values of those variables into a file in a certain order, and then would CHAIN to program
B, which would read them back in the same order.
The second method for inter programs communication involves storing the appropriate data in
otherwise unused RAM memory, outside the program/data area, where it will survive the scratch
which is implicit in a CHAIN. There are many good techniques for utilizing RAM memory in this
way, most involve the use of EXAM function and the fill statement.
TESTING FOR A SAFE CHAIN
If the file specified in a CHAIN statement does not exist, is not of type 2, or does not hold a valid
BASIC program, the CHAIN operation will fail. It is not easily possible to check an alleged program
stored on disk to be certain that it is in perfect condition, but the built in file functions may be used
to determine if a given program file exists and is of type 2 before an attempt is made to CHAIN to
it. Use of the ERRSET statement may also help in such situation.
SEE ALSO:
Statements CHAIN, READ#, WRITE#, FILL, ERRSET
Section FUNCTIONS (in detail the built in EXAM, FILE functions)
Section ERROR TRAPPING AND RECOVERY
NSB8
Rel. 5.10
Page 105