bas7advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CHAIN Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
CHAIN transfers control from the current program to another program.
 
CHAIN filespec$
    ■ The argument filespec$ is a string expression; can include a path
      specification. (With DOS 2.1 or earlier versions, you cannot use
      CHAIN unless filespec$ provides a complete path, including drive.)
    ■ Programs running within the QBX 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 QBX environment assume an .EXE
      extension and cannot chain to BASIC source files (files with a .BAS
      extension).
 
Usage Notes
    ■ You can pass variables between programs using the COMMON statement
      to set up a blank COMMON block. See COMMON Statement.
    ■ When you compile a program outside the QBX environment, the
      BCL71EFR.LIB library does not support COMMON. There are two ways to
      use COMMON with chained programs outside the environment:
 
        1. Use the default (BRT71EFR.EXE for DOS and OS/2 real mode;
           BRT71EFR.DLL for OS/2 protected mode) by compiling the programs
           using the option in the "Make EXE" dialog box called
           "EXE Requiring BRT Module."
        2. Use BRT71EFR.LIB by compiling from the command line without the
           /O option.
 
    ■ When programs use BRT71EFR.EXE or BRT71EFR.DLL, files are left open
      during chaining unless they are explicitly closed with a CLOSE.
 
      ║ Note:  The filenames BCL71EFR.LIB, BRT71EFR.EXE, and BRT71EFR.DLL
      ║        assume that you selected these compiler options when you
      ║        installed BASIC: emulator floating-point math, far strings,
      ║        and real mode. If you used different options, see "About
      ║        Linking and Libraries" in the Programmer's Guide for
      ║        information on compiler options.
 
    ■ CHAIN is similar to RUN; the main differences are that RUN closes
      all open files and does not support data blocks declared with
      COMMON.
 
Differences from BASICA
    ■ BASICA assumes the extension .BAS. the current version of BASIC
      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 BASICA and in the current version of BASIC.
    ■ The current version of 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.