Microsoft KB Archive/65503

= No CHAIN with ALL, MERGE, DELETE, or Line # in Compiled Basic =

Article ID: 65503

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft GW-BASIC 3.2
 * Microsoft GW-BASIC 3.22
 * Microsoft GW-BASIC 3.23

-



This article was previously published under Q65503



SUMMARY
The parameter of the CHAIN statement is a string expression that identifies the program to which control is passed. In compiled Basic, the filespec may include a path specification, but does not allow any other options. This differs from the GW-Basic and BasicA interpreters. QuickBasic does not support the ALL, MERGE, DELETE, or line-number options of the CHAIN statement available in BasicA and GW-Basic. The ALL option, however, can be simulated by using QuickBasic's COMMON statement to share variables between CHAINed programs.



MORE INFORMATION
GW-Basic and BasicA interpreter programs assume the extension xxxx.BAS on a CHAINed-to file. Basic compiler 6.00 and 6.00b, Basic PDS 7.00 and 7.10, and QuickBasic 4.00, 4.00b, and 4.50 compiled programs assume an extension of xxxx.BAS within the QB.EXE or QBX.EXE environment, or an extension of xxxx.EXE if compiled and run outside the environment. (In the QB.EXE environment of QuickBasic 2.00, 2.01, or 3.00, you can CHAIN only to xxxx.EXE files, so you must either omit the filename extension or specify xxxx.EXE.) To simplify using the CHAIN filespec argument, just omit the name extension on the filespec, which works the same in all versions of compiled or interpreted Basic.

Compiled Basic does not support the ALL, MERGE, DELETE, or line-number options of the CHAIN statement available in BasicA or GW-Basic. In GW-Basic and BasicA programs, CHAIN with ALL specifies that all variables in the current program are passed to the CHAINed-to program. This effectively makes every variable COMMON to each program. CHAIN with MERGE leaves any OPENed files open, preserves the current OPTION BASE setting, and merges new line numbers from the CHAINed program by numerical position. Using CHAIN with MERGE also means that any DEFINT, DEFSNG, DEFDBL, DEFSTR, or DEF FN statement need not be restated in the CHAINed program. The CHAIN with DELETE allows the programmer to delete a range of line numbers from the CHAINing program to make room for the new lines in a CHAIN MERGEd program. Without the line-number option, execution always starts at the beginning of the program.

The interpreter's CHAIN ALL option can be simulated by using compiled Basic's COMMON blocks.

Files can be left open across a chain if you compile the program to require the run-time module (compile without /O).

For more information on the syntactical differences between QuickBasic and GW-Basic/BasicA programs, see Page 312 in the &quot;Microsoft QuickBasic 4.5: Programming In Basic&quot; manual for QuickBasic version 4.50.

Additional query words: QuickBas BasicCom

Keywords: KB65503

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.