Specifications

4-26
Guide to Printers and Printing
Example of Print Formatter
This example shows how print formatters can interact with the documented printer formatter
subroutines. The procedure for writing a print formatter involves four steps:
1. Creating a print formatter source file as shown below
2. Creating an imports file
3. Creating an exports file
4. Compiling and linking the print formatter
Create the Print Formatter Source File
Use an ASCII editor to create a formatter source file named sample.c. The file should
contain the following lines:
#include <stdio.h>
#include <piostruct.h>
/* STRING CONSTANTS */
/* Initialize Printer, Restore Printer, Form Feed */
#define INIT_CMD ”ci”
#define REST_CMD ”cr”
#define FF_CMD ”af”
/* INTEGER and STRING VARIABLES */
/* page length, page width, top margin, bottom margin */
#define Pglen (*(_Pglen + piomode))
#define Pgwidth (*(_Pgwidth + piomode))
#define Tmarg (*(_Tmarg + piomode))
#define Bmarg (*(_Bmarg + piomode))
/* indentation, begin page, form feed?, pass–through? */
#define Indent (*(_Indent + piomode))
#define Beginpg (*(_Beginpg + piomode))
#define Do_formfeed (*(_Do_formfeed + piomode))
#define Passthru (*(_Passthru + piomode))
/* initialize printer?, restore printer? */
#define Init_printer (*(_Init_printer + piomode))
#define Restoreprinter (*(_Restoreprinter + piomode))
/* Command names: form feed, vertical increment and decrement */
#define Ff_cmd (*(_Ff_cmd + piomode))
#define Vincr_cmd (*(_Vincr_cmd + piomode))
#define Vdecr_cmd (*(_Vdecr_cmd + piomode))
/* Work variables for vertical increment and decrement */
#define Vincr (*(_Vincr + piomode))
#define Vdecr (*(_Vdecr + piomode))
/* Variables referenced by above #defines */
int *_Pglen, *_Pgwidth, *_Tmarg, *_Bmarg, *_Indent, *_Beginpg, *_Do_
formfeed, *_Passthru, *_Init_printer, *_Restoreprinter, *_Vincr, *_V
decr;
struct str_info *_Ff_cmd, *_Vincr_cmd, *_Vdecr_cmd;