Microsoft KB Archive/81167

= QBasic LPRINT Uses Only LPT1 =

Article ID: 81167

Article Last Modified on 11/16/2006

-

APPLIES TO


 * Microsoft MS-DOS 5.0 Standard Edition
 * Microsoft MS-DOS 5.0a
 * Microsoft MS-DOS 6.0 Standard Edition
 * Microsoft MS-DOS 6.2 Standard Edition
 * Microsoft MS-DOS 6.21 Standard Edition
 * Microsoft MS-DOS 6.22 Standard Edition

-



This article was previously published under Q81167



SUMMARY
The LPRINT command in QBasic expects a printer to be connected to the LPT1(PRN) port. If a printer is not connected to LPT1 and LPRINT is used, QBasic displays a &quot;Device fault&quot; error message.



MORE INFORMATION
To use the LPRINT command when a printer is connected to a port other than LPT1, do the following:  If the printer is connected to a COM port, the MS-DOS MODE command can be used to redirect printing from LPT1 to COMx.

For example, to redirect to COM1, use the following command:

MODE LPT1=COM1

If you need to cancel the redirection when finished, use the following command:

MODE LPT1

 MS-DOS allows you to treat all devices as if they were files. Use the QBasic OPEN command to open a port as a file and then print to the port.

Sample QBasic code to print using LPT2:

OPEN &quot;LPT2:&quot; for random as #1

PRINT #1, &quot;Text to be printed&quot;

-or-

WRITE #1, Text to be printed

CLOSE #1



The QBasic WRITE command does not need quotation marks surrounding the text to print; however, PRINT does. The CLOSE command writes the data out to a file (the printer). The CLOSE command should only be used after all PRINT or WRITE commands are executed.

Additional query words: 6.22 5.00 5.00a 6.00 6.20

Keywords: KB81167

-

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

© Microsoft Corporation. All rights reserved.