PREJOB, PREPAGE, POSTJOB, POSTPAGE

Top  Previous  Next

PREJOB, PREPAGE, POSTJOB, POSTPAGE

 

Syntax

 

prejob | postjob | prepage | postpage {

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 document generation process.  They represent four 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 (or less, depending on program size limits imposed by the run-time environment).

 

*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 or databases, prepare SQL statements or 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.
*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.

 

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.

You may use the following variables and functions in your code block:

 

*text$[all] is a one-dimensional array of the text for the page.  For example, text$[2] is the second line of the page.
*mid(arg1$,arg2,arg3) (or fnmid$(arg1$,arg2,arg3)) is a function that safely returns a substring without generating an error 47 if the value in arg1$ isn't long enough to accommodate position arg2 and length arg3.
*get(col,row,length) (or fnget$(col,row,length)) is a function that safely returns text from the text$[all] array, without substring or array out-of-bounds errors.
*set(col,row,length,value$) (or fnset$(col,row,length,value$)) is a function that places value$ in the text$[all] array at the place indicated.  It returns value$.
*err=next may be used for any err=label option in any function or statement, in order to force UnForm's error trapping to ignore an error.  You may, of course, name your own err=label if desired.

 

When using variables and line labels, you should avoid using any values that begin with "UF_". UnForm reserves all such variables and labels for its own use.  You may use a backslash (\) at the end of a line to continue the statement on the next line.  Lines prefixed with "#" are not added to the code.

 

A discussion of programming in Business Basic is outside of the scope of this manual.  If your needs require programming, then it would be advisable to hire a professional Business Basic programmer, acquire training for a technical member of your staff, or contract with SDSI for your needs.

 

Column definitions can also have code blocks, which are executed as each row of a column definition is generated.  See the coldef keyword for more information.