Microsoft KB Archive/28208

= Printing Delayed when DOS PRINT Command Invoked from SHELL =

Article ID: 28208

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 2.0
 * Microsoft QuickBasic 2.01
 * Microsoft QuickBasic 3.0
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q28208



SUMMARY
If you invoke the MS-DOS PRINT.EXE or PRINT.COM utility during a SHELL, the printer output does not print until you exit QuickBasic. This problem occurs because MS-DOS Print is a terminate-and-stay-resident (TSR) program.

CAUTION: You should never install a TSR program, such as MS-DOS Print, with the SHELL statement because it fragments memory. This can result in the error &quot;Out of Memory&quot; or &quot;Program Too Large to Fit in Memory,&quot; or it may hang the computer. You must reboot to eliminate the memory fragmentation.

If you must SHELL to a TSR program, it must have been installed in memory before running the QuickBasic program. Note: Many TSR programs may conflict with QuickBasic with other symptoms, and may not be compatible.

Instead of SHELLing to Print, Microsoft recommends simply SHELLing to the MS-DOS COPY statement, which can copy files to the logical printer device name, as follows:

shell &quot;copy c:\myfile.txt LPT1:&quot;

-or-

shell &quot;copy c:\myfile.txt PRN&quot;

This information applies to Microsoft QuickBasic versions 2.0, 2.01, 3.0, 4.0, 4.0b, and 4.5 for MS-DOS, and to Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS.



MORE INFORMATION
We do not recommended you use MS-DOS Print, or any TSR program, with QuickBasic. Because of a memory conflict, the printing will be delayed when the MS-DOS Print is invoked during the execution of a SHELL command.

In the first example below, printing occurs immediately because the Print is invoked (that is, loaded into memory) before running QuickBasic. In this case, Print takes a portion of memory for its buffer, QuickBasic loads, the SHELL executes, and the previously allocated buffer is used.

If MS-DOS Print is initially invoked by the SHELL statement itself, then printing does not occur until after exiting QuickBasic. In this case, QuickBasic loads, the SHELL executes, and Print tries to set up the buffer but does not have enough room, so it spools. Once memory is freed, either after exiting QuickBasic or after the SHELL is executed, a print buffer can be allocated and the MS-DOS Print is executed. Similar limitations occur in earlier versions of the QuickBasic compiler.

Below is the first example. MS-DOS Print is loaded before running QuickBasic, and no delayed printing occurs in the following example:

 Invoke MS-DOS Print utility. Resident portion of Print gets loaded into memory. Invoke the QuickBasic editor (QB.EXE).  Run the following program: CLS Shell &quot;print filename&quot; End 

Below is the second example. MS-DOS Print is loaded by the SHELL statement itself, and printing is delayed until after leaving QuickBasic, and memory is fragmented in the following example:


 * 1) Reboot your machine.
 * 2) Invoke the QuickBasic editor (QB.EXE).
 * 3) Run the above program. Print loads resident portion.

Additional query words: QuickBas BasicCom 2.00 3.00 4.00 4.00b 4.50 7.00 7.10

Keywords: KB28208

-

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

© Microsoft Corporation. All rights reserved.