Microsoft KB Archive/60967

= Dynamic Arrays, Far Strings Overwrite COMMAND.COM =

Article ID: 60967

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS

-



This article was previously published under Q60967



SUMMARY
If the far heap is used for any reason during the execution of a Basic program, the transient part of COMMAND.COM may have to be reloaded after its execution. COMMAND.COM occupies an area of the far heap that some features of Microsoft's Basic compilers use. If COMMAND.COM does need to be reloaded and cannot be found in the current path, the system prompts you to insert a disk containing it.

This information applies to Microsoft QuickBasic Compiler versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler versions 6.00 and 6.00b, and to Microsoft Basic Professional Development System (PDS) version 7.00.



MORE INFORMATION
Page 14 of &quot;Advanced MS-DOS Programming, Second Edition&quot; by Ray Duncan (Microsoft Press, 1988) explains this behavior of COMMAND.COM, which applies not only to Basic, but all applications:

When an application program terminates, the resident portion of COMMAND.COM does a checksum of the transient module to determine whether it has been destroyed and fetches a fresh copy from the disk if necessary.

Many features of Microsoft's Basic compilers require use of the far heap, and thus are common destroyers of COMMAND.COM. The most common is when an executable file uses a run-time module, BRUN45.EXE for example. Another is the use of dynamic arrays, which are stored in the far heap, although using small enough arrays will not overwrite COMMAND.COM. In Basic PDS 7.00, the far strings option (/Fs) also uses the far heap, even if no strings are used in the program.

Consider this sample program: 'NOCODE.BAS 'This program contains no code If NOCODE.BAS is compiled without the /o switch (specifying use of the run-time library) or compiled with the /Fs switch under Basic PDS 7.00, COMMAND.COM has to be reloaded after execution, even though no code or data is actually present.

Consider another example: 'HUGEARAY.BAS REM $DYNAMIC DIM Array(1 TO 200, 1 TO 200) AS INTEGER Since HUGEARAY.BAS dimensions a huge, dynamic array, it overwrites COMMAND.COM. If the array were much smaller, COMMAND.COM would remain intact. Note that even larger dynamic arrays that aren't huge (over 64K) can cause COMMAND.COM to be overwritten.

Additional query words: QuickBas BasicCom

Keywords: KB60967

-

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

© Microsoft Corporation. All rights reserved.