User Guide > Using Content Extraction Language > Script Examples > Example Script 2: Multicolumn Record Reports
Was this helpful?
Example Script 2: Multicolumn Record Reports
Output Records
 
 
CheckNo
CheckDate
 
VendorNo
 
Name
CheckAmount
1
1001611
05/31/95
01-AIRWAY
AIRWAY PROPERTY
7,000.00
2
001618
05/31/95
ARROW
 
ARROWSMITH WATER
75.00
3
001618
05/31/95
02-ARROW
ARROWSMITH WATER
75.00-
4
001621
05/31/95
02-LEARNER
ROGER W. LEARNER
2,500.00
5
001668
05/31/95
01-STEV
STEVENS FREIGHT S
936.34
6
001711
05/31/95
01-ANDERS
ANDERS AUTO REP
3,524.81
7
001713
05/31/95
 
*** VOID CHECK ***
 
8
001730
05/31/95
01-COMPAQ
COMPAQ COMP CORP
5,000.00
Mailing label files such as this simple 2-up (2 columns of mailing addresses) example are a special case of the fixed format style. The input source file in this example contains the text for three-line address labels, two across the page. Some text is missing if a label is obsolete.
Note:  A far more versatile mailing label script is provided in the CXL superpack. This is simply an example script that illustrates some of the basic CXL principles behind that script.
The script reads in three lines from the input file for every two output address records. Empty lines are rejected if they are not part of obsolete labels. Label information is extracted from specific locations in the input line, from two labels per line, and stored in an array. Once all three lines are read, CATCHUP mode is used to accept the accumulated information.
The values of the variables listed in the accept statement will be displayed in the Source Data Browser in the Map Designer and written to a data file or table through the Map Designer.
Input Source File
WAYMOLENE ABEL RODNEY O. ABSHER
P.O. BOX 1055 7705 N.W. 116 ST.
PAULS VALLEY, OK 73075 OKLAHOMA CITY, OK 73162
BOBBY ALDERSON (DECEASED) SARAH ALDERSON
3609 OAK HAVEN DR.
FT WORTH, TEXAS 76119
...
CXL Script
#!djrr
#Multicolumn Record Reports
# The Field Separator built-in variable is set to space and global variables are initialized in this BEGIN statement.
BEGIN { IFS = " ";
linecount = 0;
myrec = 0;
lbl_lines = 3;
lbls_up = 2;}
# Reject all empty and non-detail lines in printout, but handle incomplete labels.
{ if (length(trim($0)) == 0) {
if (linecount != 0)
linecount = linecount + 1;
if (linecount == lbl_lines)
CATCHUP ON;
REJECT;
}
}
$0(1 2) !~ / / { REJECT; }
# WRITE ADDRESSES - Accept two addresses read from last 3 lines of 2-up
# label form. Add row variables to the accept statement, i.e.:
# accept row1[myrec], row2[myrec], row3[myrec], ... rowN[myrec];
# if your labels consists of "N" lines.
CATCHUP { myrec = myrec + 1;
accept <"Name"><30>row1[myrec],
<"Add1"><30>row2[myrec],
<"CSZ"><30>row3[myrec];
if (myrec == lbls_up) {
linecount = 0;
myrec = 0;
CATCHUP OFF;
}
}
# READ LABELS - Read three lines of 2-up label form, then CATCHUP
# Add as many repeats of the condition and rowN variable assignment as needed for labels that have N lines. Add addition rowN assignments to handle M-up labels inside each comparison:
# row1[2] = rtrim($0(39 73));
# ...
# row1[M] = rtrim($0(999 1034));
linecount < lbl_lines { linecount = linecount + 1;
if (linecount == 1) { row1[1] = rtrim($0(3 31));
row1[2] = rtrim($0(32 55));
}
if (linecount == 2) { row2[1] = rtrim($0(3 31));
row2[2] = rtrim($0(32 55));
}
if (linecount == 3) { row3[1] = rtrim($0(3 31));
row3[2] = rtrim($0(32 55));
CATCHUP ON;
}
}
Last modified date: 06/13/2022