Wednesday, September 3, 2014

A Simple SQR Form Letter Program

  • DOCUMENT can be used to create form letters
  • begins with BEGIN-DOCUMENT command and ends with an END-DOCUMENT
  • In between those commands write your letter and can insert column variables to place database column values.
  • Document Markers (placeholders) are also used to print data after DOCUMENT section.Here write your logic to print data to substitute this marker in Document section
  • Document markers are denoted with a name preceded by @ (at sign) .

Sample Form Letter written in SQR Code:

begin-program
 do call_main_procedure
end-program

begin-procedure call_main_procedure
begin-select
name
addr1
addr2
city
state
zip
 do write_letter
from customers
order by name
end-select
end-procedure !call_main_procedure

begin-procedure write_letter
begin-document (1,1)
&name
&addr1
&addr2
@city_state_zip
.b
.b
                                                                                                             $current-date
Dear All:
.b
    This is sample SQR code that creates a form letter for each customer.
Here used column variables and also Document marker city_state_zip that forms city,state and zip data in single line
and can be printed at the place holder which has been marked with symbol @.
.b
.b                           
                                                                                                                 Sincerly,
                                                                                                                 Aravind

.b
.b
end-document
position () @city_state_zip
print &city ()
print ', ' ()
print &state ()
print ' ' ()
print &zip () edit xxxxx-xxxx
new-page
end-procedure !write_letter

Output for above code looks like below shown image.




No comments:

Post a Comment