Printing Control Characters & Suppressing RETURNs in Mac BASIC (20519)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b
  • Microsoft BASIC Compiler
  • Microsoft BASIC Interpreter for Apple Macintosh 2.0
  • Microsoft BASIC Interpreter for Apple Macintosh 2.1
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0

This article was previously published under Q20519

SUMMARY

Question:

How can control characters be sent to the ImageWriter from BASIC for the Macintosh? Is there any way to suppress the automatic carriage-return (ASCII 13) character?

Response:

The information below applies to the following products:
  1. Microsoft QuickBASIC Version 1.00 1.00a 1.00b for the Apple Macintosh
  2. Microsoft BASIC Compiler Version 1.00 for the Apple Macintosh
  3. Microsoft BASIC Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh
First, note that there are two modes of printing in BASIC for the Macintosh:
  1. BASIC character mode, which includes LPRINT, or output with PRINT#n or WRITE#n to the device name "LPT1:DIRECT" or "LPT1:BIN"
  2. BASIC graphics mode, which includes output to the device name "LPT1:" or "LPT1:PROMPT" with PRINT#n, WRITE#n, or WINDOW OUTPUT #n
ImageWriter control characters CANNOT be sent to the printer device name "LPT1:" or "LPT1:PROMPT", since these devices build a special bit-mapped image in a temporary disk file for output.

ImageWriter control codes CAN be sent using LPRINT, or by OPENing "LPT1:DIRECT" or "LPT1:BIN" as #n and sending output with PRINT#n to a directly connected ImageWriter.

The "LPT1:BIN" device name outputs all characters, including the ASCII 9 (Tab), without translation. "LPT1:BIN" is thus better than LPRINT or "LPT1:DIRECT" to successfully output all control codes (such as for the task of sending ImageWriter-specific graphics control codes, byte by byte). "LPT1:BIN" is not supported in the earlier BASIC Compiler Version 1.00, but is supported in QuickBASIC Version 1.00 and the earlier Interpreter Version 3.00.

To print control characters to the printer with the LPRINT statement, you must usually suppress RETURNs on the printer with the WIDTH LPRINT 255 statement, as in the following example:
   WIDTH LPRINT 255   ' A width of 255 suppresses RETURNs.
   ' Printer control characters can now take effect. For
   ' example, ESCAPE "Q" sets ultracondensed characters
   ' on the ImageWriter (See ImageWriter printer manual):
   LPRINT CHR$(27);"Q"
   WIDTH LPRINT 130   ' Reinvokes RETURNs, at 130th character.
   FOR I=1 TO 20 : LPRINT "1234567890"; : NEXT    ' Wrap demo.
   LPRINT : LPRINT
   LLIST              ' Prints this program in ultracondensed.
				
LPRINT and "LPT1:DIRECT" are supported on directly connected ImageWriter printers only; they are not supported for AppleTalk network devices such as AppleTalk ImageWriters and LaserWriters.

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