==================================================================
CUSTOMIZING PRINTER CONTROL CODES
==================================================================
PRODUCT : R:BASE VERSION : 3.1 AND UP
CATEGORY: INSTALLATION SUBCATEGORY: CUSTOMIZING
==================================================================
We all appreciate the usefulness of our printers. They produce our
product lists, business letters, mailing labels and other printed
information. The software we use needs to take advantage of the
printers'capabilities so we can get the best possible output. Most
software products provide either printer drivers or printer control
files to help us get the most from our printers. R:BASE and Personal
R:BASE give us the option of selecting printer control files (the
control files are selected during installation of the software). The
printers Microrim provides files for are listed in Appendix C of the
Upgrade Express booklet or the Installation Guide.
If your printer is not listed, check your printer manual to see whether
it is compatible with any of the printers that are listed. Many printers
work well with the Epson1.prd file, for example. Otherwise, you can
create your own printer control file.
What Is a Printer Control File?
===============================
A printer control file is a list of printer commands, called printer
control codes. Printer control codes are a series of characters that
tell the printer what to do. When you set a printer in R:BASE, you are
selecting a printer control file that contains a certain set of printer
control codes. You can set a printer by choosing the TOOLS option on
the R:BASE Main menu, then choosing SETTINGS, then pulling down the
CONFIGURATION menu and using the PRINTER option. The printers selected
during Install will be displayed.
The control codes in a printer control file can include instructions
about printing in compressed or bold fonts, printing italics, under-
lining, and many other options. You use control codes in the reports
and labels in your databases by choosing a code from the Print Style
menu and then locating it. Reports and labels will now send that code
to the printer when you print, and the printer will then interpret the
code and print in the style you have selected!
Modifying a Printer Control File
================================
How can you tell R:BASE to take advantage of printer features that are
not listed in the Microrim-supplied printer control file? How can you
make your own printer control file? Both questions are answered below.
The printer control files that come with R:BASE are ASCII text files.
This means that you can edit and change them with any text editor,
including R:BEDIT, the R:BASE editor. You can make a new printer control
file by copying an existing file and modifying it with an editor. All
you do is add the printer control codes you want to the file, being sure
to follow the format of the existing codes.
The hard part of building a printer control file is finding the correct
printer control codes. Most printer manuals list the control codes or
tell you how to create them. Look in the appendix for a list of "escape
sequences", or control codes.
Understanding Escape Sequences
==============================
Escape sequences are groups of ASCII characters (usually preceded by the
"escape" character, (character(27) in decimal)) that the printer inter-
prets. ASCII characters or ASCII codes are the characters (letters,
numbers, and the other symbols) that are on the keys of your computer
keyboard. ASCII characters can also be represented by decimal codes and
sometimes hexa- decimal (or "hex") codes. All these codes are represen-
tations of the different ways in which the computer can store the ASCII
characters. What this all boils down to is that R:BASE printer control
codes convert decimal codes into ASCII characters.
You need to convert the escape sequences listed on the printer manual
charts into their decimal (number) equivalents and put the correct
decimal codes in the printer control files. Below is an example of a
features reference table from one printer manual.
+-----------------------------------------------------------------+
| Function Control Code Decimal Value Hexadecimal |
| ----------- ------------ --------------- -------------- |
| Landscape ESC &l10 27 38 108 49 79 1B 26 6C 31 4F |
| Orientation |
+-----------------------------------------------------------------+
You are interested only in the function, control code, and decimal
value. The hexadecimal column might be used by other software, but
R:BASE uses the decimal value. The function is what you want the printer
to do. The control code is the escape sequence or the group of ASCII
characters that tells the printer how to do this. The decimal value is
what the printer control file needs.
Notice that the value in the Control Code column starts with the letters
"ESC". This represents the escape character you would not normally see
(if you could see it, it would look like a left arrow). Most printer
control codes start with the escape key, thus the name "escape sequence"
is often used instead of "printer control code". Because most control
codes contain printable characters (such as the & or l (lower-case L
in the example above), they need to be converted to a different format,
such as decimal values. Each ASCII character has a decimal value.
To find out what a particular character's decimal value is, consult what
is known as an "ASCII chart". An ASCII chart shows each ASCII character
and its decimal (and sometimes hexadecimal) code. The R:BASE Reference
Manual (among many other reference works) includes an ASCII chart; see
"ASCII Character Codes" at the end of Chapter 6. The decimal codes for
most printer control codes are provided in the escape sequence list in
the printer manual, as in the sample of the feature reference table
shown above.
Format of an R:BASE Printer Control Code
========================================
Let's look at how R:BASE stores the decimal codes in the printer control
file and converts them into the control codes used by the printer. Here
is a line from one of the R:BASE printer control files:
#Landscape < 27 38 108 49 79 >
Notice that the numbers between the less-than (<) and greater-than (>)
brackets are the same (and are in the same order) as those listed under
the decimal value column of the escape sequence chart. R:BASE reports
and labels interpret a variable value that is a set of numbers between
less-than (<) and greater-than (>) brackets as the decimal values of a
printer control code. The values are converted to their ASCII equiva-
lents when the report or label is printed. When the variable or printer
code is located on the report or label, the ASCII codes tell the printer
what to do. This produces the print style you want.
Notice that the line from the R:BASE file starts with #Landscape. This
is interpreted as a global variable name; the "#" at the start of the
name tells R:BASE to hide the variable name from the SHOW VARIABLE
command. You can, however, use the Print Style menu in reports and
labels to show those variables and any variables that are defined in
the report or label with the < > format.
You can also include comments in the printer control file by starting
the line containing the comment with a semicolon (;).