Main BASIS Page
Main Advantage Page
This Issue's Table of Contents
Tech Resource Zone Solutions Showcase: Scaling The Internet Everest With The Basic Web Utility Table of Contents From The Top

Formerly Tid Bytes, the TRZ offers tech notes from the field written by BASIS Technical Support personnel. This regularly appearing column features practical answers to the real problems developers face on the frontline of getting their systems up and running.

Configuring Printers In PRO/5 Using Escape Sequences

By Nick Decker

The PRO/5® language runs on a variety of platforms while maintaining program and data file compatibility on each operating system. Additionally, it is able to communicate effectively with a multitude of different printers. It does this by using escape sequences, sequences of characters containing coded instructions for the printer and preceded by an ESCAPE character (ASCII code 27) to get the printer's attention. Escape sequences are also known as PCL (Printer Control Language) codes and are supported by most printers. One of the great benefits using escape sequences is that you can take advantage of any feature that any printer has to offer by configuring it via escape sequences.

What can I do with escape sequences?

By telling PRO/5 which escape sequences to send to a printer, you can configure the printer's page size, font family and point size, rows and columns, etc. The only challenging part is finding out what escape sequences your printer utilizes to manipulate these features. For example, different printers use different escape sequences to set the page size, so the escape sequences can be unique to each printer. However, many families of printers, such as Hewlett Packard's HP LaserJet series, tend to share the same escape sequences. The printer's manual should detail all of the escape sequences that it supports. Additionally, many printer manufacturers make their printer escape sequences available via their Web sites.

How do escape sequences work?

PRO/5 uses a printer alias line in the config.bbx file to fully describe any printer to which it will communicate. The escape sequences for the printer are included in the alias line and determine how PRO/5 configures the printer before use. Two common printer alias modes are SP= (standard print) and CP= (compressed print). These modes are comprised of escape sequences that determine the setup of the printer and how it will print in SP or CP mode. Here's an example CP mode for an HP LaserJet:


The hexadecimal string of numbers is a series of the escape sequences that PRO/5 sends to the printer when you want to print compressed print. Here's an explanation of the CP mode (which is specific to the LaserJet):

1B45 = Reset - The printer will revert to the default configuration
1B266C363070 = Set the Page Length to 60 lines
316F = Set to Landscape mode
3864 = Set the print to 8 lines per inch
3241 = Set the page size to Letter
1B266B3253 = Set the type pitch to compressed (16.5 - 16.7 characters per inch)

These sequences are taken directly from the HP LaserJet manual. The only difference is that PRO/5 expects the escape sequences to be in hexadecimal on the alias line, while some manuals list them in ASCII or octal representation. For example, a printer manual may say that to cause the printer to set the page length to 60 (1B266C363070 in the above example), you should supply an ESCAPE&l60p. An ASCII chart, such as the one in the PRO/5 Quick Reference Guide, can be used to translate the manual's escape sequence to hexadecimal so that a CP= mode can be created. For the given example, an ESCAPE is a 1B, an & is a 26, a l is a 6C and so on.

If I don't have the manual, where else can I find the specific escape sequences for my printer?

It's possible to get the escape sequences for some printers by printing out the test print pages provided by the manufacturer. But as is often the case, the Internet may have a solution to your problem. For example, Hewlett Packard offers Printer Configuration Wizards on its Web site that allow you to fill out a form describing how you want your page to look. These Wizards then return the ASCII version of the escape sequences you need to use to get your desired look. This way, you can bypass the manual, but you'll still need to convert these ASCII escape sequences to hexadecimal if you want to use them in PRO/5 printer aliases. These Wizards can be found at the following URLs:

For an HP LaserJet model:
For an HP model 4L / 5L / 6L, DeskJet 1600 (family printers):

Solutions Showcase: Scaling The Internet Everest With The Basic Web Utility Table of Contents From The Top

Copyright 1999, BASIS International Ltd. All rights reserved.
Terms of Use