Classic Computer Magazine Archive COMPUTE! ISSUE 86 / JULY 1987 / PAGE 56


Sheldon Leemon

Using Your Printer With The Amiga

One of the most misunderstood aspects of the Amiga is how its printer device works. Most computers use a "dumb" printer device, like the MS-DOS device PRN:, that sends each character to the printer exactly as it receives it. When you want to make your printer perform a special function, like underlining or boldface print, you use this device to send a special sequence of characters to the printer. Such a sequence of characters is sometimes called an escape code, since most start with the escape (ESC) character, ASCII character 27. Escape codes vary from printer to printer, so the command to start underlining on one printer may not mean a thing to another printer. So every IBM program has to know the specific codes for your printer in order to activate its special features. For example, each word processor comes with its own collection of printer driver files that tell it how to use the special features of each printer. Since there's no standard format for IBM printer driver files, the WordPerfect printer drivers won't work with Microsoft Word.

The Amiga's Answer

The Amiga, on the other hand, has a "smart" printer device called PRT:. This device uses the settings that you've saved with the Preferences program to find out all about your printer (these preferences are saved in a file called System-Configuration in the Devs directory of the Workbench disk). PRT: checks to see which printer you've selected from the Change Printers screen of Preferences. The device reads in the printer driver file whose filename corresponds to the printer you've selected (it looks for this file in the Devs/Printers subdirectory). This printer driver file tells PRT: what special features your printer supports and how to access them. It also contains a program for printing screen graphics on your dot-matrix printer.

With the Amiga's smart PRT: device you don't have to know the printer-specific code for each special feature. Instead, you send it an Amiga-specific code, and PRT: translates that into your printer's own code. If your program wants the printer to start underlining, for example, it sends the Amiga-specific code ESC[4m to PRT:, and PRT: sends your printer the correct code to start underlining. The important thing to remember is that not only will the PRT: device not respond to your printer-specific escape codes, it will also not even pass them on to your printer. Any escape code that PRT: doesn't recognize will be ignored.

Of course, you can still send escape codes directly to your printer via the Amiga's dumb printer device, PAR:. This device sends characters straight through to printers connected on the parallel port. The SER: device sends them to serial printers. But if at all possible, you should try using the Amiga's codes and PRT:. That way, your program will work with any printer, and, should you happen to switch printers six months down the road, you won't have to rewrite the program completely.

The following short BASIC program shows you how to send commands to your printer through either the dumb or smart printer devices. Since the Toshiba printer that I use is not that common, odds are the sample codes used for the PAR: device won't work with your printer. But, the PRT: version should work with any printer, provided that the proper printer driver is installed from Preferences.

AS = "Condensed Print is ON"
BS = "Condensed Print is OFF"
' PAR: device – works only with
Toshiba printer
F$ = CHR$(27) + "[" + A$
G? = CHR5(27) + "]" + B$ + CHR$(
' PRT: device – works with ANY p
F$ = CHR$(27) + "[4w" + A$
G$ = CHR$(27) + "[3w" + BS
PRINT #1,: PRINT #1, FS;G$

A full list of Amiga printer escape codes can be found on pages 22–25 of "Introduction to Amiga Update" in the manual that comes with Version 1.2 of AmigaDOS. Here are a few of the more co­monly used codes. Remember that ESC stands for CHR$(27), the escape character.

Feature On Off
Italics ESC[3m ESC[23m
Underline ESC[4m ESC[24m
Bold ESC[lm ESC[22m
Expanded ESC[6w ESC[5w
Condensed ESC[4w ESC[3w

The secret to using PRT: is having the correct printer driver file installed on your Workbench disk. What if you have an odd printer that isn't supported directly? First, you might try finding a public-domain driver on a BBS or an information service, or a commercial driver from a software company. But if you can't find one, you might try making one yourself with a shareware program called PrtDrvGen by Jorgen Thomsen. This impressive program can help create a driver for almost any conceivable printer, from 8 pins to 24 pins, black-and-white or color. The program comes with a fantastic set of help screens that give a great deal of insight into how PRT: uses the printer drivers. At a suggested donation of $10, it's the best software bargain of the year. You can contact Jorgen on CompuServe (ID 71310,2206) or PeopleLink (J.THOMSEN).