Previous Next Chapter

Using Printer Escape Sequences

Each printer has its own set of escape sequences that are used in programs to control that particular printer's features. There are also standard ANSI escape sequences that control special printer features. By using the ANSI escape sequences, you can create a program that can be used on any printer for which there is a printer driver without making changes. We recommend using the standard ANSI escape sequences; however, do not confuse or mix your printer's escape sequences with these since they are likely to be different.

The Amiga printer device (PRT:) accepts standard ANSI escape sequences. The active printer driver translate ANSI escape sequences into control sequences your printer understands. For example, you can use escape sequences to set margins, turn on styles such as boldface or italics, and specify spacing. If a feature is not supported by your printer or printer driver, the escape sequence for it is ignored. Consult your printer documentation to verify the feature settings your printer accepts.

Escape sequences are typically used when you print to the printer device directly from the Shell or when you insert print commands into a program.

A typical escape sequence (to turn on boldfacing) is shown as follows:

Esc[1m

This indicates that you must press the following keys in sequence: Esc, [, 1, m. Escape sequences are case-sensitive. For example, to enter the following escape sequence:

Esc[4W

press the Esc, [, 4, and Shift+W keys.

Numbers inserted into the escape sequence are indicated by <n>. For example, the escape sequence used to set the left and right margins is:

Esc[<n>;<n>s

If you want to specify a left margin of 5 and a right margin of 75, type:

Esc[5; 75s

To send an escape sequence to the printer from the Shell:

  1. Redirect the keyboard input to the printer by entering:

1> COPY * to PRT:

  1. Wait until disk activity stops and type an escape sequence, such as:

Esc[2"z

To terminate keyboard output to PRT:, press Ctrl+\.

You can also create printer command files consisting of several escape sequences by redirecting keyboard input to a file. For example:

  1. Redirect the keyboard input to a file:

1> COPY * TO RAM:EscapeFile

  1. Enter the escape sequences, such as:

Esc[2"z (turns near letter quality on)

Esc[2w (turns elite type on)

Esc[1m (turns boldface on)

  1. Press Ctrl+\ to terminate keyboard output to the file.
  2. To send these escape sequences to the printer, enter:

1> COPY RAM:EscapeFile TO PRT:

Top Previous Next Chapter