Sample Program for Form Letters

The following simple form letter program, ex10a.sqr, demonstrates the use of document markers:

Program ex10a.sqr 
begin-program
  do main
end-program
begin-procedure main
begin-select
name
addr1
addr2
city
state
zip
  do write_letter
from customers
order by name
end-select
end-procedure ! main
begin-procedure write_letter
begin-document (1,1)
&name
&addr1
&addr2
@city_state_zip
.b
.b
                                                $current-date
Dear Sir or Madam:
.b
     Thank you for your recent purchases from ACME Inc. We would like 
     to tell you about our limited-time offer.
     During this month, our entire inventory is marked down by 25%. 
     Yes, you can buy your favorite merchandise and save too.
     To place an order simply dial 800-555-ACME. 
     Delivery is free too, so don't wait.
.b
.b
                                Sincerely,
                                Clark Axelotle
                                ACME Inc.
end-document
position ()  @city_state_zip
print &city  ()
print ', '   ()
print &state ()
print ' '    ()
print &zip   () edit xxxxx-xxxx
new-page
end-procedure ! write_letter

First, SQR performs the main procedure and the select paragraph. Next, it performs the write_letter procedure and the document paragraph. The POSITION command sets the position to the appropriate line, which is given by the @city_state_zip marker. The program prints the city, and then it continues printing the other elements to the current position. The state name and zip code automatically print in the correct positions with appropriate punctuation.

The following sample is the output for program ex10a.sqr:

John Conway
2837 East Third Street
Greenwich Village
New York, NY 10002-1001       


10-MAY-2004

Dear Sir or Madam:     

Thank you for your recent purchases from ACME Inc. We would like to tell you 
about our limited-time offer. 

During this month, our entire inventory is marked down by 25%. Yes, you can 
buy your favorite merchandise and save too. To place an order simply dial 
800-555-ACME. Delivery is free too, so don't wait.

                                
                                Sincerely,
                                Clark Axelotle
                                ACME Inc.

See Adding Graphics.