Release 10.1A: OpenEdge Deployment:
Managing 4GL Applications

> ## 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. The printer-control table 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 a Progress `UPDATE` statement to interpret the printer-control sequences and enter them into a printer-control table. For example, the Progress `UPDATE` statement interprets the octal sequence ~017 as the character string:

>     [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. Figure 7–4 shows a sample printer-control table.

> Figure 7–4: 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:
>       PUT cust-num name address city st zip.
>     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.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095