Examples
The following example demonstrates how to split an input print stream into two print streams based on the number of pages in the document, then adds OMR marks to one output and a DataMatrix barcode to another.
<input>
<name> INPUT <! Identifiable name. >
<file> DD:INPUT1 <! Input file name. >
<type> AFPL A <! AFP line data w/ANSI controls.>
<doc> T %%AcctNum CHANGE <! Top of document when Account changes.>
<field> %%AcctNum KA <! Find all occurrences. >
<ref> ' ' 'Account Number:' 44 <! Reference starts in column 44>
<loc> 0 2 8 <! Same line as reference, move 2 >
</field> <! column, get 8 bytes. >
</input>
<rule>
<content> <! Rule file is instream. >
START:
%%OMRCount = 0
%%Counter = 0
<! If a one page document, set OMR marks and route to that output.>
DOCUMENT:
if %%TOTAL_PAGES = 1 then
%%OMRCount = %%OMRCount + 1 <! setup OMR mark and >
if %%OMRCount > 7 then <! write to first output >
%%OMRCount = 1
endif
<output> Output1
<! Document must have more than one page. So set the DataMatrix barcode>
<! and route to the appropriate output. >
else
%%Counter = %%Counter + 1
%%Doc = JUSTIFY(%%Counter,R,5,0)
%%Barcode = SUBSTR(%%AcctNum,1,3) | SUBSTR(%%AcctNum,5,4) | %%Doc
%%ChkDigit = CHECKSUM(%%Barcode)
<output> Output2
endif
</content>
</rule>
<output>
<name> Output1 <! Identifiable name. >
<file> DD:OUTPUT1 <! Output file name. >
<add>
<addtype> OMR <! OMR mark for 1 page documents >
<addpart> 1 1 <! Mark used for Benchmarking >
<addpart> %%OMRCount 3 <! Variable set in rule for 3 bytes.>
<position> .5 6 in <! Placement of OMR marks. >
</add>
</output>
<output>
<name> Output2 <! Identifiable name. >
<file> DD:OUTPUT2 <! Output file name. >
<add>
<addtype> DataMatrix <! DataMatrix barcode for 2+ page documents. >
<addpart> * <! Framing character >
<addpart> %%Barcode 12 L ' ' <! 12-bytes, left justified. >
<addpart> %%ChkDigit 1 L ' ' <! 1-byte check digit. >
<addpart> * <! Framing character >
<position> .5 10.5 0 0 IN <! Placement of DataMatrix barcode.>
<datamatrix> Y 1 <! Square barcode with minimal error correction. >
<cellsize> 12 PELS <! Width and height of one cell. >
</add>
</output>
The following illustrates how to create a Code 3of9 barcode with framing characters (*) on each end. The example barcode contains the current page number, the total number of pages, the customer number, and the document number.
<ADDPART> * <! always include framing character>
<ADDPART> %%PAGE_NO 3 R 0 <! a system variable >
<ADDPART> %%TOTAL_PAGES 3 R 0 <! a system variable>
<ADDPART> %%customer 3 R 0 <! a user-defined field variable>
<ADDPART> %%SEQUENCE_NO 3 R 0 <! a system variable>
<ADDPART> * <! always include framing character>
You could achieve the same results by building a single variable in a PAGE: rule that contains all of the necessary information, as shown next.
In the control file:
<ADDPART> %%barcode 14 R 0
In the PAGE: rule:
%%barcode = '*'| %%PAGE_NO | %%TOTAL_PAGES | %%customer | %%SEQ_NO | '*'
Note: Since page number is part of the barcode, the value of %%barcode must be set in a PAGE: rule. Otherwise, you should set the value in a DOCUMENT: rule.