This example shows how an application program calls and uses a program-described printer file to control how your printed output will look.
This example consists of:
This is the RPG-coded application program. The numbers within the program correspond to the list on the following pages. That list explains how this program works and specifically how the program opens and uses the printer file.
Note: Read the Code disclaimer information for important legal information.
********************************************************************* FADDRESS IF E K DISK (1) FLABELPRTO F 132 OF PRINTER ********************************************************************* CTAR 20 1 CSAR 30 1 STAR 2 1 ZPAR 8 1 READ ADDRESS 10 *IN10 DOWEQ'0' ADD2 IFEQ *BLANKS MOVE '1' *IN55 ELSE MOVE '0' *IN55 END EXSR CKCITY ********************************************************************* (2) EXCPTPRINT ********************************************************************* READ ADDRESS 10 END ********************************************************************* (3) MOVE '1' *INLR ********************************************************************* CKCITY BEGSR MOVEA*BLANKS CTAR MOVEA*BLANKS STAR MOVEA*BLANKS ZPAR MOVEA*BLANKS CSAR MOVEACITY CTAR MOVEAST STAR MOVEAZIP ZPAR Z-ADD1 X 20 Z-ADD1 Y 20 EXSR LOOKBL 1ST WORD. ADD 1 X CTAR,X IFGT *BLANKS 2ND WORD MOVE ' ' CSAR,Y ADD 1 Y EXSR LOOKBL
(4) ADD 1 X CTAR,X IFGT *BLANKS 3RD WORD MOVE ' ' CSAR,Y ADD 1 Y EXSR LOOKBL END END MOVE ',' CSAR,Y ADD 1 Y MOVE ' ' CSAR,Y ADD 1 Y MOVE STAR,1 CSAR,Y ADD 1 Y MOVE STAR,2 CSAR,Y ADD 1 Y MOVE ' ' CSAR,Y ADD 1 Y MOVE ' ' CSAR,Y ADD 1 Y Z-ADD1 X X DOWLT9 MOVE ZPAR,X CSAR,Y ADD 1 Y ADD 1 X END MOVEACSAR CTSTZP 30 ENDSR LOOKBL BEGSR CTAR,X DOWGT*BLANKS MOVE CTAR,X CSAR,Y ADD 1 X ADD 1 Y END ENDSR ********************************************************************* RTE 1 2 PRINT NAME 25 E 1 PRINT ADD1 25 (5) E 1 N55 PRINT ADD2 25 E 1 PRINT CTSTZP 30 E 1 55 PRINT *********************************************************************
Open processing
Part (1) of the application program opens files that are called by the application program.When a program opens files, an object of type *FILE is connected to the program for processing. Among the files opened in this example, and of particular interest at this point, is the printer file whose name is LABELPRT. You can find the printer file name LABELPRT next to the (1) in the program listing.
A printer file is opened to prepare the system so that the application can put data into a spooled file or print it out directly to a printer. Information from the high-level language application program, the printer file, and any printer file overrides is combined.
The printer file open operation is controlled by parameters specified in the printer file, the high-level language program, and in printer file overrides (through the Override with Printer File (OVRPRTF) command). See Printer file overrides for more information on overrides.
As an example, if the printer file specified lines per inch (LPI) of 8, and an OVRPRTF command specified an LPI of 6, the LPI of 6 would be used since the override value specified by the OVRPRTF command takes precedence over the LPI value specified in the printer file.
The following list contains parameters from the printer file LABELPRT. These are the parameters that the application program accesses or looks at when it opens the printer file. They are the majority of the parameters in the printer file, but not all of them. When the application looks at each parameter, it finds a value specified for each parameter. For a description of each parameter, see the Create Printer File (CRTPRTF) CL command.
FILE DEV DEVTYPE CVTLINDTA PAGESIZE LPI UOM CPI OVRFLW RPLUNPRT FIDELITY CTLCHAR PRTQLTY FORMFEED DRAWER OUTBIN FONT CHRID DECFMT FNTCHRSET CDEFNT PAGDFN FORMDF AFPCHARS TBLREFCHR PAGRTT PRTTXT JUSTIFY DUPLEX IPDSPASTHR USRRSCLIBL CORNERSTPL EDGESTITCH SADLSTITCH FNTRSL SPOOL SCHEDULE USRDTA SPLFOWN USRDFNOPT USRDFNDTA USRDFNOBJ IGCDTA IGCEXNCR IGCCHRTT IGCCPI IGCSOSI IGCCDEFNT WAITFILE SHARE LVLCHK AUT TEXT
Output processing
Part (2) of the application program performs the operations of reading, compiling, and sending the output to the output queue specified in the OUTQ parameter of the CRTPRTF command or to the printer specified in the DEV parameter of the CRTPRTF command. In this example, the SPOOL parameter has a value of (*YES). This means the output will become a spooled file in the designated output queue.The following printer file parameters are the CRTPRTF parameters looked at by the system program and application program during the output processing portion of the application program. For a description of each parameter, see the CRTPRTF CL command.
This example does not use a DDS source file. Thus, when the application program calls the printer file LABELPRT and looks at the SRCFILE parameter, the value will be *NONE. Since no DDS will be used, the high-level language must provide the programming to control how the printed output will look. This example contains the high-level language code in part (5) of the example program listing.
SRCFILE SRCMBR FOLD ALIGN CHLVAL PRTTXT REDUCE MULTIUP FRONTMGN BACKMGN FRONTOVL BACKOVL MAXRCDS DFRWRT
Close processing
Part (3) of the application program performs the close operations of the application program.When the application program has finished the output processing part of the application program, it performs a close operation on all the files it opened during the open processing portion of the application program.
The following printer file parameters from the CRTPRTF command are the parameters looked at by the system program and the application program during the close portion of the application program. For a description of each parameter, see the CRTPRTF CL command.
SCHEDULE
Output from the example
Ann White Box 123 RR 1 Anytown, IA 12345 Tom Smith 123 Main St. Somewhere, IN 54321