Escape Sequences

Escape Sequences

An escape sequence consists of the ESC control code followed by one or more characters in succession. Both two-character and structured escape sequences control the printer. Two-character escape sequences take the form ESCX, where X is a character from the ASCII table (0 through ~).

Structured escape sequences take the following form:

ESCXy[parameter]Z

This sequence is explained below:

ESCXy Prefix. This part of the escape sequence indicates that the escape sequence is structured and also specifies which type of control is being performed. “X” is referred to as the structured character; “y” is referred to as the group character.

Parameter This string of ASCII characters specifies a value (either numeric or alphanumeric).

ZTerminator. This ASCII character indicates the function to which the previous parameter value applies. If this character is lower case (a,b,c, etc.), it indicates a combined escape sequence, meaning that more structured information will follow. If the character is upper case (A,B,C, etc.), it terminates the escape sequence string.

NOTE: Brackets [ ] are shown in many of the escape sequences for clarification purposes, but are not actually part of the escape sequence. For example, the brackets in the escape sequence for selecting page length (ESC&l[1-128]P) specify a range of values (1 through 128) for page length. To specify a page length of 35 lines, the escape sequence ESC&l35P would be sent to the printer.

Combining Escape Sequences

Structured escape sequences can be combined to save keystrokes. Combining sequences involves adding the parameter value and terminator of one or more sequences to another escape sequence. Structured sequences can be combined only if their prefixes are identical. When a parameter/ terminator of one sequence is added to another sequence, all of the terminators except the last should be lower case. For example, to set the left and right margins using two separate escape sequences, the following two sequences would be sent:

Set left margin at position 10

ESC&a10L

Set right margin at position 99

ESC&a99M

Using one combined escape sequence, the following would be sent to the printer:

ESC&a10l99M

15

Page 15
Image 15
Compaq 5525B/31/32 manual Combining Escape Sequences