HP-UX SNAplus2 RJE User's Guide

Program Output with PDIRs
Output Program Example
Appendix A 163
#trailer = trailer PDIR
#start header = first byte of header, start_trailer = first byte
#of trailer
((trailer = end -1))
((start_header = ${offset[1]} + 1))
((start_trailer = ${offset[trailer]} + 1))
#cp the header and trailer to temporary files
cat $output_file | catrje $start_header ${offset[2]} > \
$output_file.header
cat $output-file | catrje $start_trailer ${offset[end]} > \
$output_file.trailer
#Create output files consisting of header, body, trailer
#Body is created by starting at first byte after the PDIR
#offsets and terminating at byte offset of next PDIR.
#This code looks at the COPIES value for each body, and prints
#out more than one copy if specified. Other PDIR values can
#also be examined and used.
while ((count < trailer))
do
((num_copies = ${copies[count]} + 1))
((start_body = ${offset[count]} + 1))
cat $output_file | catrje $start_body ${offset[count + 1]} \
> $output_file.body
printer=”lp -n$num_copies”
cat $output_file.header $output_file.body \
$output_file.trailer | $printer
((count = count + 1))
done
rm -f $output_file.header
rm -f $output_file.body
rm -f $output_file.trailer