|
personally for things like this I 've always tended to call a script
from a simple blp (that does nothing else usually but it could put in
the first/only header before calling the script). The script uses
MERGE_LINE and GET OA$MERGE_LINE="...bla..." to build the output
counting lines as it does. You probably have to have a bit of logic
like "build a complete record and store the lines in # symbols, work
out how many lines it takes, will it fit on the current page? if yes,
output it line by line, if not MERGE_LINE "<&PAGE>" then output the
record line by line. The script can read thru your selections using
either NEXT_LIST or the TEXTFILE functions.
Hope this helps.
Andy
|
| If this helps, here's part of a HINTs and HACKS guide I wrote a while
back...
3.1. Complex boilerplate processing
Consider the following simple boilerplate...
Details of POSTBOOK entry NO. <$POSTBOOK>
Mail Type : <$POSTBOOK:1> (I=Incoming,O=Outgoing)
Addressee : <POSTBOOK_ENTRY.TO[$POSTBOOK]>
<POSTBOOK_ENTRY.TADD1[$POSTBOOK]>
<POSTBOOK_ENTRY.TADD2[$POSTBOOK]>
Sender : <POSTBOOK_ENTRY.SENDER[$POSTBOOK]>
<POSTBOOK_ENTRY.SADD1[$POSTBOOK]>
<POSTBOOK_ENTRY.SADD2[$POSTBOOK]>
Subject : <POSTBOOK_ENTRY.SUBJECT[$POSTBOOK]>
For an INCOMING mail, no details are input for the Addressee's address,
so the resulting file will look something like...
Details of POSTBOOK entry NO. I0123
Mail Type : I (I=Incoming,O=Outgoing)
Addressee : Mr Michael Murphy
Sender : Mr Patrick O'Shaunessy
Blarney Stone Merchants
10 High Road, Cork, Ireland
Subject : New shovels
For an OUTGOING mail, no details are input for the Sender's address, so
the resulting file would look something like this...
Details of POSTBOOK entry NO. O1001
Mail Type : O (I=Incoming,O=Outgoing)
Addressee : Mr Patrick O'Shaunessy
Blarney Stone Merchants
10 High Road, Cork, Ireland
Sender : Mr Michael Murphy
Subject : Confirmation of delivery of new shovels
In each case, we are outputting two blank lines that do not lend to the
aesthetic value of the document. Also, the "Mail Type" line is not
pleasing. We could either use a different boilerplate for each type of
mail (i.e. I and O) or we could still use one boilerplate but make it
more intelligent! It is the latter that will be discussed here...
For both types of mail, the first line of text outputted will be the
same, so we code thisin the boilerplate as before. From then on, the
format of the outputted text is dependent on which kind of mail it is, so
we need to call a script. The final line outputted (the Subject) is the
same for both kinds of mail, and so we code this into the boilerplate.
Our boilerplate now looks like this...
Details of POSTBOOK entry NO. <$POSTBOOK>
<&OA DO POSTBOOK_MERGE>
Subject : <POSTBOOK_ENTRY.SUBJECT[$POSTBOOK]>
The boilerplate is processed, line by line, by the MERGE function. Each
line (including the blanks) is written to the output file in turn, with
the symbol contents in place of the directives. When the "<&OA DO...>"
directive is processed, a script is called instead. From within this
script we can build more lines of text and by assigning them to a special
symbol, "OA$MERGE_LINE", can output them to the file we are creating.
When the script has completed, control returns to the MERGE function and
it continues to process the boilerplate line by line. For our example of
"Mr Murphy's Executive Shovel Emporium" the script, "POSTBOOK_MERGE.SCP",
would look something like this...
!+
! POSTBOOK_MERGE.SCP
!_
.LABEL START
!
! put out "Mail Type" line + blank line
.IF $POSTBOOK:1 EQS "I" THEN GET #IN_OUT = "Incoming" -
ELSE GET #IN_OUT = "Outgoing"
GET OA$MERGE_LINE="Mail Type : " #IN_OUT
GET OA$MERGE_LINE=""
!
! put out first line of Addressee (always)
GET OA$MERGE_LINE="Addressee : " POSTBOOK_ENTRY.TO[$POSTBOOK]
!
! do we need the TO address, if not skip it
.IF $POSTBOOK:1 EQS "I" THEN .GOTO MERGE_SENDER
!
! else put out the To address (2 lines) + blank line
GET OA$MERGE_LINE=" " POSTBOOK_ENTRY.TADD1[$POSTBOOK]
GET OA$MERGE_LINE=" " POSTBOOK_ENTRY.TADD2[$POSTBOOK]
GET OA$MERGE_LINE=""
.LABEL MERGE_SENDER
!
! put out first line of Sender (always)
GET OA$MERGE_LINE="Sender : " POSTBOOK_ENTRY.SENDER[$POSTBOOK]
!
! do we need the SENDER address, if not finish
.IF $POSTBOOK:1 EQS "O" THEN .EXIT
!
! else put out the To address (2 lines)
GET OA$MERGE_LINE=" " POSTBOOK_ENTRY.SADD1[$POSTBOOK]
GET OA$MERGE_LINE=" " POSTBOOK_ENTRY.SADD2[$POSTBOOK]
.EXIT
So, our resulting output for INCOMING mail will look like...
Details of POSTBOOK entry NO. I0123
Mail Type : Incoming
Addressee : Mr Michael Murphy
Sender : Mr Patrick O'Shaunessy
Blarney Stone Merchants
10 High Road, Cork, Ireland
Subject : New shovels
For an OUTGOING mail, the resulting output will look something like
this...
Details of POSTBOOK entry NO. O1001
Mail Type : Outgoing
Addressee : Mr Patrick O'Shaunessy
Blarney Stone Merchants
10 High Road, Cork, Ireland
Sender : Mr Michael Murphy
Subject : Confirmation of delivery of new shovels
Clearly, this is a fairly trivial example but the same principle can be
applied when writing applications that require considerably more complex
processing; for example, controlling page breaks, widows and orphans,
different headings on each page etc.
|