Microsoft KB Archive/45899

= CHAIN MERGE Can Repeatedly Append Second Program to First =

Article ID: 45899

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft BASIC Interpreter 1.0
 * Microsoft BASIC Interpreter 1.01 for Macintosh
 * Microsoft BASIC Interpreter 2.0
 * Microsoft BASIC Interpreter 2.1 for Macintosh
 * Microsoft BASIC Interpreter 3.0 for Macintosh
 * Microsoft GW-BASIC Interpreter 3.20
 * Microsoft GW-BASIC Interpreter 3.23
 * Microsoft GW-BASIC Interpreter 3.22
 * Microsoft GW-BASIC Interpreter 3.23

-



This article was previously published under Q45899



SUMMARY
When using the CHAIN MERGE &quot;filename&quot; statement, you must specify the line number where execution is to begin; otherwise, the program restarts from the beginning and reruns the same CHAIN MERGE statement (unless program logic avoids it) in a repeating cycle.

This information applies to the interpreter in Microsoft QuickBASIC Version 1.00 for Apple Macintosh, Microsoft BASIC Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh, and Microsoft GW-BASIC Interpreter Versions 3.20, 3.22, and 3.23 for MS-DOS.



MORE INFORMATION
Note that in QuickBASIC Version 1.00 for Macintosh and in the BASIC interpreter Versions 2.00, 2.10, and 3.00 for Macintosh, the CHAIN MERGE statement does not merge numbered lines in numerical order, since line numbers, like labels, can be in any order. Instead, CHAIN MERGE appends the CHAINed program to the end of the CHAINing program.

In Microsoft GW-BASIC Interpreter for MS-DOS and in the BASIC interpreter Versions 1.00 and 1.01 for Macintosh, line numbers are required on every line, and the CHAIN MERGE statement interleaves (rearranges) line numbers in numerical order.

Code Example
When the first program below is run, it prints &quot;it1&quot;, appends the second program to the first, restarts execution at the first line of the first program, and prints &quot;it1&quot; again. This process repeats without stopping, reappending the second program and printing &quot;it1&quot; each time.

To have this program run and stop without repeating itself, add a starting line number to the CHAIN MERGE statement so it starts on the first line in the second (merged) program.

The following is program &quot;it1&quot; (which must be saved in ASCII text mode): 10 PRINT &quot;it1&quot; 20 CHAIN MERGE &quot;it2&quot; ' 30 CHAIN MERGE &quot;it1&quot;, 100   ' use this command instead The following is program &quot;it2&quot; (which must be saved in ASCII text mode): 90 PRINT &quot;it2&quot; ' 100 PRINT &quot;it2&quot;          ' use this PRINT line instead

Additional query words: MQuickB

Keywords: KB45899

-

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

© Microsoft Corporation. All rights reserved.