Telling QB to Wrap (Not Truncate) Wide Lines on HP LaserJet (71235)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 7.1
  • Microsoft QuickBASIC 3.0
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b

This article was previously published under Q71235

SUMMARY

When printing program listings to a Hewlett-Packard (HP) LaserJet II from the ALT+File+Print menu option in QB.EXE or QBX.EXE, long lines exceeding 80 columns will be truncated to 80 columns rather than wrapped to the next line. This is due to the default no-wrap mode of the HP LaserJet II series, and can be changed by sending the appropriate escape code to the printer (as described below).

This information applies to Microsoft QuickBasic 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) versions 7.00 and 7.10.

MORE INFORMATION

Because QB.EXE and QBX.EXE make no assumptions about the printer type or page layout, long print lines are sent to the printer as they are, with no pre-formatting. This can be a problem if a particular printer has no provisions for wrapping long lines. Fortunately, most printers have either a DIP switch setting for line wrapping or, more often, an escape code that can be sent to the printer to enable or disable line wrapping.

With the Hewlett-Packard LaserJet II series, the code sequence to enable line wrapping is ESC+"&s0C", where ESC is the byte value returned by the CHR$(27) function, and the quotation marks are not part of the sequence. The code sequence to disable line wrapping is:
   ESC+"&s1C"
				
For other laser printers, please refer to the printer's manual for appropriate control codes.

The following sample programs will enable and disable line wrapping on the HP LaserJet II series printers:

Sample Program

REM This program enables line wrapping on HP LaserJet printers.
REM You can run this program before printing a program listing that
REM has lines wider than 80 characters.
OPEN "LPT1:" FOR OUTPUT AS #1
PRINT #1, CHR$(27); "&s0C";
CLOSE #1
END
 
REM This program disables line wrapping on HP LaserJet printers.
OPEN "LPT1:" FOR OUTPUT AS #1
PRINT #1, CHR$(27); "&s1C";
CLOSE #1
END
				

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