Specifications

4-14
Guide to Printers and Printing
Printer Colon File Escape Sequences
Embedded references and logic for attribute values in the printer backend’s database colon
files are defined with escape sequences placed at appropriate locations in the attribute
string. These escape sequences are not to be confused with printer escape sequences. The
first character of each escape sequence is always the % (percent sign) character, which
indicates the beginning of an escape sequence. The second character (and sometimes
subsequent characters) define the operation to be performed. The remainder of the
characters (if any) in the escape sequence are operands used to perform the specified
operation.
Calculations performed by the escape sequences can use a stack to hold integers or
pointers to strings to be operated on and can use internal variables a through z to save
integer values for later use.
Because the % character is used to define the beginning of an escape sequence, a %
character that is part of the data must be represented in the database as two adjoining %
characters (%%). Only one % character appears in the constructed string.
The escape sequences that can be specified in an attribute string are listed and described
in the following table. They are based on the terminfo file escape sequences for terminals,
which have been modified and extended for printers.
Esc. Seq. Description
%% Generates a % (percent sign) character.
ASCII Output from Stack:
%d Pops an integer value from the stack and converts it to ASCII,
without leading zeros. Produces a field width large enough to hold
the ASCII numeric digits. Similar to %d with the printf subroutine.
%[1–9]d Pops an integer value from the stack and converts it to ASCII. The
result is 1 to 9 characters long, depending on the digit specified
before the d. If the value does not fill the specified field width, it is
padded on the left with zeros. If the value will not fit in the field,
excess high–order digits are discarded. For example, with a value
of 243 from the stack, %4d produces 0243 and %2d produces 43.
A stack value of –243 would cause %5d to produce –0243.
B inary Output From Stack:
%c Pops an integer value from the stack and discards all but the
low–order byte.
%h Pops an integer value from the stack and discards all but the two
low–order bytes.
%a Similar to %h, except that the two bytes from the stack are in an
alternate order: low–order byte, then high–order byte.