Printing Delayed when DOS PRINT Command Invoked from SHELL (28208)



The information in this article 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
  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 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 "Out of Memory" or "Program Too Large to Fit in Memory," 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 "copy c:\myfile.txt LPT1:"

-or-

shell "copy c:\myfile.txt PRN"

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:

  1. Invoke MS-DOS Print utility. Resident portion of Print gets loaded into memory.
  2. Invoke the QuickBasic editor (QB.EXE).
  3. Run the following program:
          CLS
          Shell "print filename"
          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.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB28208