Tech Tip
unForm -- Advanced code block Techniques
Page control example:
convert document trailer page with email info
to a single delimited line on the main page
so that the eDeliver engine can process it
without a new method type ...
We know that's a mouthful, but we've been waiting for a
good real-world example to show you how unForm 7.x new page control functions
work.
This example uses the following page control functions
and internal variables:
- getpage
- delpage
- uf.maxpage
- array1$[]=array2$[]
(There are other unForm functions employed, as well.)
Note that these images of the Tech Tip sample come from the
form and rule set loaded in the unForm Design Tool.
... first a little Background:
unForm's standard eDeliver "engine" rule set allows for four different methods
for obtaining the delivery recipient. Currently, this does not include a trailer
page kind of scenario. SDSI used the method described here to convert a trailer
page scenario into a delimited line scenario so that the eDeliver engine could
be adapted for this situation. Currently this method is not incorporated in the
engine, but is performed in the originating enhancement rule set.
Here's the text sample that is the input file, with
comments:
Here's what the rule file looks like. Each pertinent section is highlighted
and/or numbered.
Below the image are numbered comments that describe what's going on.
- 1
Prejob code block
Has the first page in memory, but has access to all pages in the text stream
via the 'getpage' ( ) function. The trailer page is the last page in
the text stream.
- 2 if not(uf.subjob)
The eDeliver engine is going to process the email in an unForm subjob using
the same ruleset as the main job that may be printing, and is launching the
email process. Since the subjob by default uses the same ruleset, and the
text file stored for the subjob will already exclude the trailer page by the
time it is processed, we only need to execute the logic in this portion of
the ruleset inside the main job. The internal global variable uf.subjob is
set to 1 automatically by unForm when the subjob is launched, so this
variable can be used to make ruleset processing logic conditional on being
in the main job versus the subjob.
- 3 edel$=get(1,2,10,1,uf.maxpage)
Get the data at column 1, row 2, for a length of 10, on the last page of the
print stream. On the text sample, this is the line that has the word EMAIL
on it.
- 4 Page processing
If a valid eDelivery tag was found using the previous get function, do the
following:
getpage(uf.maxpage,epg$[]) - put the last (trailer) page into a
new array called epg$[]
delpage (uf.maxpage) - delete the last (trailer) page
text$[]=epg$[] - move the last page data into the text$[]
"current page" array. The text$[] array is the standard internal variable
that all page text is loaded into when a page is read in. Because we are in
prejob, if we don't need any of the data on page 1, we can simply replace it
with the data we want from the last page. When unForm is ready to process
the first page it reads it in a second time.
The reason we are "moving" the trailer page data to the first page and the
text$[] array is because then we can use the standard get functions to
access the information, as shown in the next section.
- 5 switch/case logic for each eDeliver type
Now that the trailer page is in the "memory" of the text$[] array, the get
function is used to grab each line and add it to the delimited line string
being created. After it is created it will be placed on the page when the
prepage codeblock for the first page is processed.
- 6 Prepage code block -- text$[1]+=deline$
If it is the first page, append to the first line the delimited line built
up in the previous step.
- 7 Test text command
A text command prints the contents of the delimited line variable, so that
we can see all of the data.
The command in the middle section that reads:
edelbo$=sub(mget(1,7,80,10,"y","y"),$0a$,"\n"))
has converted the linefeed characters to "\n" using the sub
(substitute) function so that the text won't break and create extra lines
when it is taken from the trailer page and added to the main document page.
UnForm's text command has been designed to recognize the "\n" characters as a line feed
Here's the output page, with highlights and comments.
Obviously this is only one of what are many possible applications for use of
these functions.
"Smart Form" code-blocks: one of unForm's important features for developers and
integrators who need to take total control of the forms and document processing
environment.
|