ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzalu_5.4.0.1/rzaluprogramexmp.htm

293 lines
12 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="dc.language" scheme="rfc1766" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<meta name="dc.date" scheme="iso8601" content="2005-09-06" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow"/>
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<title>Example: Using a program-described printer file with an application
program</title>
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
<link rel="stylesheet" type="text/css" href="ic.css" />
</head>
<body>
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
<a name="rzaluprogramexmp"></a>
<h3 id="rzaluprogramexmp">Example: Using a program-described printer file with an application
program</h3>
<p>This example shows how an application program calls and uses a program-described
printer file to control how your printed output will look.</p>
<p>This example consists of:</p>
<ul>
<li>An RPG-coded application program that produces mailing labels.</li>
<li>A printer file that is opened by the application program when the application
program runs.</li>
<li>A detailed listing of which parameters from the printer file are used
by the application program and at what point during the processing of the
application program they are used.</li></ul>
<p>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.</p>
<ul>
<li>Part <span class="bold">(1)</span> opens the printer file.</li>
<li>Part <span class="bold">(2)</span> sends the output to the designated output
queue.</li>
<li>Part <span class="bold">(3)</span> closes the opened files.</li>
<li>Part <span class="bold">(4)</span> processes the data.</li>
<li>Part <span class="bold">(5)</span> provides the code to control how the printed
output will look.</li></ul>
<p><span class="bold">Note:</span> Read the <a href="rzalucodedisclaimer.htm#rzalucodedisclaimer">Code disclaimer information</a> for
important legal information.</p>
<p></p>
<pre class="xmp">*********************************************************************
FADDRESS IF E K DISK
<span class="bold">(1)</span> 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
*********************************************************************
<span class="bold">(2)</span> EXCPTPRINT
*********************************************************************
READ ADDRESS 10
END
*********************************************************************
<span class="bold">(3)</span> 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
</pre><p class="indatacontent"> </p>
<pre class="xmp"><span class="bold">(4)</span> 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
<span class="bold">(5)</span> E 1 N55 PRINT
ADD2 25
E 1 PRINT
CTSTZP 30
E 1 55 PRINT
*********************************************************************</pre>
<p><span class="bold">Open processing</span></p>
<p></p><blockquote>Part <span class="bold">(1)</span> of the application program opens files
that are called by the application program.
<p>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 <span class="bold">(1)</span> in the program listing.</p>
<p>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.</p>
<p>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 <a href="rzaluoverride.htm#rzaluoverride">Printer file overrides</a> for more
information on overrides.</p>
<p>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.</p>
<p>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 (<a href="../cl/crtprtf.htm">CRTPRTF</a>)
CL command. </p>
<pre class="xmp">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</pre></blockquote>
<p><span class="bold">Output processing</span></p>
<p></p><blockquote>Part <span class="bold">(2)</span> 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.
<p>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 <a href="../cl/crtprtf.htm">CRTPRTF</a> CL command.</p>
<p>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 <span class="bold">(5)</span> of the example program listing.</p>
<p></p>
<pre class="xmp">SRCFILE
SRCMBR
FOLD
ALIGN
CHLVAL
PRTTXT
REDUCE
MULTIUP
FRONTMGN
BACKMGN
FRONTOVL
BACKOVL
MAXRCDS
DFRWRT</pre></blockquote>
<p><span class="bold">Close processing</span></p>
<p></p><blockquote>Part <span class="bold">(3)</span> of the application program performs
the close operations of the application program.
<p>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.</p>
<p>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 <a href="../cl/crtprtf.htm">CRTPRTF</a> CL command. </p>
<pre class="xmp">SCHEDULE</pre></blockquote>
<p><span class="bold">Output from the example</span></p>
<p></p><blockquote>
<pre class="xmp">Ann White
Box 123
RR 1
Anytown, IA 12345
Tom Smith
123 Main St.
Somewhere, IN 54321
</pre></blockquote>
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
</body>
</html>