Try OpenEdge Now
skip to main content
Managing ABL Applications
ABL and R-code Deployment and Management : Managing Print Devices : Configuring a printer : Creating a printer-control table
 
Creating a printer-control table
It is important to note that control sequences are hardware dependent. Applications with hard-coded printer-control sequences are not easily transportable. You cannot change the print devices that the application accesses without changing the hard-coded printer-control sequences in the application. To bypass this obstacle, create a printer-control table which contains a record for each printer on your system. Each record in the printer-control table must contain a field for the name of the print device and several other fields containing a corresponding set of standard control sequences.
There is no easy way to employ an ABL UPDATE statement to interpret the printer-control sequences and enter them into a printer-control table. For example, the ABL UPDATE statement interprets the octal sequence ~017 as the character string, as shown:
[TILDE][ZERO][ONE][SEVEN]
Instead of the proper code sequence:
[CONTROL-0]
You can create a system administration procedure that lets you convert printer-control sequences into the appropriate ASCII character strings, and store the printer-control sequences as ASCII character strings in the fields of a printer-control table.
Keep the printer-control table up to date with a record for each printer on your system. The following image shows a sample printer-control table.
Figure 10. Sample printer-control table
The field containing the print device name must index the table. In this sample control table, the outdev field indexes the table.
To access the proper control sequences for a printer from a printer-control table, set up an include file to determine the print device used in the application, then substitute the corresponding control sequences into the PUT CONTROL statements of the application. For example:
FIND Usrprnt WHERE Usrprnt.userid = USERID NO-ERROR.
IF AVAILABLE Usrprnt
THEN DO:
OUTPUT THROUGH VALUE(Usrprnt.outdev).
FIND Prntcfg WHERE Prntcfg.outdev = Usrprnt.outdev NO-ERROR.
END.
ELSE DO:
OUTPUT TO PRINTER.
FIND Prntcfg WHERE Prntcfg.outdev = "default".
END.
The include file searches the Usrprnt table to determine the output device (Usrprnt.outdev) for the current user ID. After determining the output device, the include file searches the printer-control table to find the appropriate control sequences for the current printer. Notice that the printer-control table contains a default entry for the default printer.
The PUT CONTROL statements in your application should use a field in the printer-control table or a variable name to access the proper control sequence for the current printer. This allows you to change print devices without recoding the printer-control sequences for all the PUT CONTROL statements in your application. For example:
{output2.i}.
PUT CONTROL Prntcfg.compres.
FOR EACH Customer NO-LOCK:
  PUT Customer.CustNum Customer.Name Customer.Address Customer.City     Customer.State Customer.PostalCode.
END.
PUT CONTROL Prntcfg.ucomprs.
In this procedure, the first PUT CONTROL statement turns on compressed printing, and the second PUT CONTROL statement turns off compressed printing for the current print device.