The PRINTER.DLL is a dynamic link library that provides a series of printer function. The PRINTER.DLL is the best tool for creating form letters where there is variable text combined with static text. The word static is in quotation marks because there might be several variations of text that are used depending on the variables themselves.
The following example demonstrates why you might want to use the PRINTER.DLL for form letters, and how to generate them. The Accounts Receivable Deapartment at ABC Co. needs to send out letters to customers to update their account status. There are, however, three versions of the letter depending on whether the balance is positive, negative or zero. You could use the Revelation Reporter to do this; however, you would need to use calculated fields for the static text portion of the letter. This would clutter up your dictionary with items that are application-specificnot data-specific. As a result, you would not be able to reuse these items in any tool other than the Revelation Reporter. By using the PRINTER.DLL, you create a program that encapsulates the logic to prepare and output the information based on a defined structure and format.
The following elements below illustrate the example:
The columns used in the ABC Co. Accounting Status Update Form Letter
The Three Required Form Letters
PRINTER.DLL Functions, Syntax and Parameters
The Code Used to Generate the Three Form Letters
The columns used in the ABC Co. Accounting Status Update Form Letter
COLUMN NAME | Column Explanation |
FNAME | First Name |
LNAME | Last Name |
ADDRESS | Street Address |
CITY | City |
STATE | State |
ZIP | Zip Code |
ACCTNUM | Account Number |
SALUTATION | Mr., Mrs., Miss, or Ms. |
ACCBAL | Account Balance (<0 is a credit) |
ACCDUE | Date Balance Due |
ACCREP | Customer s Account Rep |
ACCEXT | Account Rep s Telephone Extension |
The Three Required Form Letters
Letter generated when Balance>0 ABC Co. Account Status [FNAME] [LNAME] [ADDRESS] [CITY], [STATE] [ZIP] Account#: [ACCNUM] Dear [SALUTATION] [LNAME], Your account reflects a balance of [ACCBAL] as of[Today s Date]. Please remit payment by[ACCDUE] to avoid finance charges. Please call[ACCREP] at (800) 555-1234 ext. [ACCEXT]regarding any questions about your account. Sincerely, Jane Smith, Manager of Accounts Receivable | Letter generated when the Balance=0 ABC Co. Account Status [FNAME] [LNAME] [ADDRESS] [CITY], [STATE] [ZIP] Account#: [ACCNUM] Dear [SALUTATION] [LNAME], Your account reflects a balance of $0 as of [Today s Date]. Please call [ACCREP] at (800) 555-1234 ext. [ACCEXT] regarding any questions about your account. Sincerely, Jane Smith, Manager of Accounts Receivable | Letter generated when the Balance<0 ABC Co. Account Status [FNAME] [LNAME] [ADDRESS] [CITY], [STATE] [ZIP] Account#: [ACCNUM] Dear [SALUTATION] [LNAME], Your account reflects a credit of [ACCBAL] as of[Today s Date]. Please call [ACCREP] at (800) 555-1234 ext [ACCEXT] regarding any questions about your account. Sincerely, Jane Smith, Manager of Accounts Receivable |
PRINTER.DLL Functions, Syntax and Parameters
Function | Description | Syntax | Parameters |
Print _End() | Terminates the print job. | status = Print_End() | |
Print_Init() | Starts a printing session. | Status = Print_Init(mode,jobtitle, handle) | mode: 0=default printer; 1=displays the Print dialog box jobtitle: the print job title to appear in Print Manager handle: handle of the owner window |
PrintLineFeed() | Advanced printing to a new line or allows a font change on the current line. | Status = PrintLineFeed(mode) | mode: 0=same line; 1=new line |
PrintNewPage() | Inserts a page break. | Status = PrintNewPage() | |
PrintPageStatus() | Returns the number of lines to the end of page. | PrintPageStatus(1) | returns the # of lines to the end of the page |
PrintRect() | Prints a rectangle relative to the page, beginning at the top left and extending to the bottom right coordinate of the rectangle measured in inches. | Status = PrintRect(top, left, bottom, right) | top, left, bottom, right: respective positions of margin in inches |
PrintSetBrush() | Sets the style, hatch, and color of the brush as defined by the Windows SDK. | Status = PrintSetBrush(style, hatch, color) | style: as defined in PRINT_EQUATES, and Windows SDK; 0=solid line; 1=hollow line; 2=hatched line; 3=patterned line; hatch: as defined in PRINT_EQUATES and Windows SDK; 0=horizontal line; 1=vertical line; 2=forward diagonal line; 3=backward diagonal line; 4 crossed line color: RGB based color |
Print_SetFont() | Sets the font for the text to be printed. | Status = Print_SetFont(font) | font: structure of the font as returned by Utility ( CHOOSEFONT ) |
Print_SetFooter() | Sets the page footer print and font. | Status =Print_SetFooter(footertext, lines, font) | footertext: text for the footer lines: total # of lines to leave at bottom (inc. text in footer) font: structure of the font as returned by Utility ( CHOOSEFONT ) Note: Footer is limited to one line. @FM is not supported in the footer. |
Print_SetHeader() | Sets the page header print and font. | Status =Print_SetHeader(headertext, font) | headertext: text for the header font: structure of the font as returned by Utility ( CHOOSEFONT ) Note: In order for lines of text to wrap, each line must be delimited by an @FM. |
PrintSetMargins() | Sets the margins for the page to be printed for the printable area of the page. | Status = PrintSetMargins(top, left, bottom, right) | top, left, bottom, right: respective positions of margin in inches |
PrintSetPen() | Sets the style, width, and color of the pen as defined by the Windows SDK. | Status = PrintSetPen(style, width, color) | style: as defined in PRINT_EQUATES, and Windows SDK; 0=solid line; 1=dashed line; 2=dotted line; 3=dash-dot line; 4=dash-dot-dot line width: # of thousandths of an inch color: RGB based color |
Print_Text | Outputs a single line of text to the printer. | Status = Print_Text(text) | text: text to print Note: \PAGE will print the current page number. This can be used in conjunction with any of the printer functions. |
The Code Used to Generate the Three Form Letters
function example(hwnd)
* Declare functions to be used
declare function Print_Init, PrintSetMargins, Print_SetFont, Print_SetHeader, Print_Text, PrintLineFeed,PrintNewPage, Print_End
declare function Get_Property, Utility
Ctrl = @window: ".ACCTNUM"
Table = Get_Property(Ctrl, "TABLE")
open "DICT",Table to @dict else null
@id = Get_Property(Ctrl, "INVALUE")
@record = Get_Property(@window, "RECORD")
@mv = ""
status=print_init(0,"test document",hwnd)
* Enable end user to select font at runtime from the font menu *
FontStruct=utility("CHOOSEFONT", @Window)
status=Print_SetFont(FontStruct)
* Set the margins *
status=PrintSetMargins(1,1,1,1)
* Set the print header to show the company name. *
status=Print_SetHeader("ABC Co. Account Status")
* Print the customer info. *
status=PrintLineFeed(1)
status=Print_Text({FNAME}:" ":{LNAME})
status=Print_Text({ADDRESS})
status=Print_Text({CITY}:", ":{STATE}:" ":{ZIP})
status=PrintLineFeed(1)
status=Print_Text("Account #:":{ACCTNUM})
status=PrintLineFeed(1)
* Print the salutation. *
status=Print_Text("Dear ":{SALUTATION}:" ":{LNAME}:",")
* Establish which letter body to print and print appropriate text *
BEGIN CASE
CASE {ACCBAL}=0
status=Print_Text("Your account reflects a balance of $0 as of ":(OConv(Date(), "D4")):".")
CASE {ACCBAL}<0
status=Print_Text("Your account reflects a balance of ":trim({ACCBAL,2}):" as of ":(OConv(Date(), "D4")):". ")
status=Print_Text("We will send you a refund check in the mail.")
CASE {ACCBAL}>0
status=Print_Text("Your account reflects a balance of ":trim({ACCBAL,2}):" as of ":(OConv(Date(), "D4")):". ")
status=Print_Text("Please remit payment by ":OConv({ACCDUE},"D4"):" to avoid finance charges. ")
END CASE
* Print rest of letter *
status=Print_Text("Please call ":{ACCREP}:" at (800) 555-1234 at ext. ":{ACCEXT}:" regarding ")
status=Print_Text("any questions about your account.")
status=PrintLineFeed(1)
status=Print_Text("Sincerely,")
status=Print_Text("Jane Smith, Manager of Accounts Receivable")
status=PrintLineFeed(1)
*Insert page break *
status=PrintNewPage()
status=Print_End()
return status