PRECOPY, PREDEVICE, PREJOB, PREPAGE, POSTCOPY,...

Top  Previous  Next

Syntax

 

precopy | postcopy | prejob | predevice | postjob | prepage | postpage | postdevice {

code block

}

 

Note:  the opening brace "{" needs to be on the same line as the keyword.   The closing brace may follow the last statement, or be on the line below the last statement.

 

Description

 

These keywords are used to add Business Basic processing code to the form or report.  They represent six different subroutines that UnForm executes at specific points during processing.  The code block can be an arbitrary number of Business Basic statements; the total number of statements in all code blocks can be about 6,000.

 

*prejob executes after the rule set has been read, and after the first page is read, but before any printing takes place.  Use this code to open files, define string templates, create user-defined functions, and initialize job variables.
*postjob executes after the last page has been printed.  Use this to close out your logic, such as adding totals to log reports.  There is no need to close files, since UnForm will RELEASE Business Basic.
*predevice executes just after a device has been opened.  With the laser driver, the output device can be changed with the output command or by modifying the output$ variable in a prepage or precopy code block.  Whenever a new device is opened for any given copy, this code block is executed.  The programmer can then store information from the page that causes the device to be opened, such as a customer code or fax information.
*postdevice executes just after the output device has been closed.  Use this code block to perform processing with prior output device, once UnForm has closed the device.  For example, if the output device changed when the customer number changed, then one or more pages for a given customer would be in the output file and could be sent as a group to a fax product.
*prepage executes after each page is read, but before any printing takes place.  Use this to gather data associated with any page, or to modify the content of the text if you need such modifications to apply to all copies.
*postpage executes after the last copy of each page has printed.
*precopy executes before each copy is printed.  Use this to modify copy text content, to skip specific copies, or to modify a copy's output device.
*postcopy executes after each copy is printed.

 

Any valid Business Basic programming code can be entered, including I/O logic, loops, variable assignments, and more.  Program to your heart's content.  UnForm will add extensive error handling code within your code, and report syntax errors to the error log file or a trailer page.

 

Note that the merge command, while not executable code, is honored within a code block.  The merged data must be valid code block syntax.

 

For more details about programming code blocks, see the Programming Code Blocks chapter.

 

Example:

 

This example shows how to use various routines to make copy 2 of a form be a conditionally faxed invoice, using a CSV formatted file containing a customer ID and a fax number.

 

prejob {

exportfile$="/exports/faxnums.csv"

today$=dte(0:"YYYY-MM-DD")

faxlog$="/exports/logs/fax"+today$+.log"

}

 

prepage {

invoice$=get(65,5,7)

custid$=get(65,4,6)

custname$=trim(get(10,10,35))

faxnum$=getfilefield(exportfile$, custid$, 2)

}

 

precopy {

if copy=2 then:

if faxnum$>"" then:

output$="|fx -n "+faxnum$

log(invoice$+"  "+custid$+" "+custname$, faxlog$)

 end if

end if

}

 

 

Drivers: all, but predevice and postdevice are only supported by pcl, ps, and pdf drivers.