Microsoft KB Archive/45899

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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 "filename" 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 "it1", appends the second program to the first, restarts execution at the first line of the first program, and prints "it1" again. This process repeats without stopping, reappending the second program and printing "it1" 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 "it1" (which must be saved in ASCII text mode):

   10 PRINT "it1"
   20 CHAIN MERGE "it2"
   ' 30 CHAIN MERGE "it1", 100    ' use this command instead
                

The following is program "it2" (which must be saved in ASCII text mode):

   90 PRINT "it2"
   ' 100 PRINT "it2"           ' use this PRINT line instead
                


Additional query words: MQuickB

Keywords: KB45899