Understanding the Sample Program for Printing Mailing Labels
The following sample program prints mailing labels in a format of 3 columns by 10 rows. It also counts the number of labels that is printed and prints that number in the last sheet of the report.
Program ex9a.sqr
#define MAX_LABEL_LINES 10
#define LINES_BETWEEN_LABELS 3
begin-setup
declare-layout default
paper-size=(10,11) left-margin=0.33
end-declare
end-setup
begin-program
do mailing_labels
end-program
begin-procedure mailing_labels
let #label_count = 0
let #label_lines = 0
columns 1 29 57 ! enable columns
alter-printer font=5 point-size=10
begin-select
name (1,1,30)
addr1 (2,1,30)
city
state
zip
move &zip to $zip XXXXX-XXXX
let $last_line = &city || ', ' || &state || ' ' || $zip
print $last_line (3,1,30)
next-column at-end=newline
add 1 to #label_count
if #current-column = 1
add 1 to #label_lines
if #label_lines = {MAX_LABEL_LINES}
new-page
let #label_lines = 0
else
next-listing no-advance skiplines={LINES_BETWEEN_LABELS}
end-if
end-if
from customers
end-select
use-column 0 ! disable columns
new-page
print 'Labels printed on ' (,1)
print $current-date ()
print 'Total labels printed = ' (+1,1)
print #label_count () edit 9,999,999
end-procedure ! mailing_labels