qb45advr.hlp (Topic list)
CHAIN Statement Details
  QuickSCREEN      Details      Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
CHAIN Statement Details
 
Syntax
  CHAIN filespec
 
The filespec is a string expression that identifies the program to
which control is passed. The filespec may include a path
specification.
  ■ Programs running within the QuickBASIC environment assume
    a .BAS extension (if no extension is given) and cannot chain
    to executable files (files with a .COM or .EXE extension).
  ■ Programs running outside the QuickBASIC environment assume
    an .EXE extension and cannot chain to QuickBASIC source files
    (files with a .BAS extension).
 
You can pass variables between programs using the COMMON statement
to set up a blank COMMON block. See the entry for COMMON.
 
If you are compiling a program outside the QuickBASIC environment,
note that the BCOM45.LIB library does not support COMMON. There
are two ways to use COMMON with chained programs outside the
environment.
 ■ Use the default (BRUN45.EXE) by compiling the programs using the
   option in the Make EXE dialog box called EXE Requiring BRUN45.EXE.
 ■ Use BRUN45.LIB by compiling from the command line without the /O
   option.
 
The behavior of CHAIN and RUN is almost identical. The principal
differences are that RUN closes all open files and does not support
COMMON data blocks.
 
  Note: When programs use BRUN45.LIB, files are left open during
        chaining unless they are explicitly closed with a CLOSE
        statement.
 
Difference from BASICA
 
BASICA assumes the extension .BAS. QuickBASIC assumes an extension
of either .BAS or .EXE, depending on whether the program is run within
the environment or compiled and run outside the environment. If you
omit the file extension, CHAIN works the same in both QuickBASIC
and BASICA.
 
BASIC does not support the ALL, MERGE, or DELETE options available in
BASICA, nor does it allow you to specify a line number.
 
Without the line-number option, execution always starts at the
beginning of the chained-to program. Thus, a chained-to program that
chains back to a carelessly written chaining program can cause an
endless loop.