This solution first appeared on Baanfans on July 19, 1999 at 04:23:11 EST. It works only with Unix print queues and not with BWPrint (either Unix or Windows).
~Vamsi
Mohanavamsi Potluru
<hr>
<h1>"Page of" using Barcode-Functionality</h1>
A completly other way of printing the number of pages is to use Barcode-Functionality.
The Barcode-Feature (Warning : Works only for UNIX-Printers) is in fact a API-Interface for
printing. You can merge everything you want to an existing spool. And the merging ist done
after Baan has createed the whole printing, so Baan also knows the total amount of pages.
<p>
I tried my example with an Easy-SQL and it works really fine.
<p>
In short the example works like that:
<ul>
<li>Before printing I generate a unique Spool number and print it (!!) on the report in
a field, which is connected to a Barcode
<li>At the end of printing I write the unique number and the number of pages to an ASCII-File
<li>In the filter-Program of Baan (which puts the correct Escape-Sequences to a spool) I take the
Barcode-Script (which gets the unique number as parameter) and read the corresponding
number of pages. Instead of a barcode i merge the number of pages in the Spool - Output
<p><center><b>--> there we are !!!!</b></center>
</ul>
<p>
The greatest problem is not getting the Page - number, but managing the unique numbers.
<p>
<h2> How to use the example</h2>
<ul>
<li>Print in the header of your report something like "Page : VVVVVVV of FFFFFFFF",
where FFFFFFFF is the new field
(in my example <i>int.unique.s</i> of type tcmcs.str8 and with Barcode - Type 95)
Dont care of the warning : "Input field not declared" . <b>Do not declare the field as input field</b>
<li>Warning: I think there is an error in the Baan-Barcode-API, because, when the Barcode-Field
is the last field in a line the Printer-Daemon gets mad, so i added a "." (= point) after the
barcode-Field and everything works fine. (Note: a empty field of 1 Byte works also)
<li>paste the code on this site to the report-script
<li>create (once) a subdirectory under your $BSE_TMP-folder named "printing". Make sure, that
everyone has accessrights for this directory.
<li>for each Baan-Printer(device), you have to connect the printer to a Baan- Printer-information-File
(see "technical manual" in the online help). Normally every UNIX-printer is
already connected to a Printer-Driver
<li>for each (unix-)printer you want to work with this feature you have to change
the printer driver file ($BSE/lib/printinf/.....), so that it contains a link to a
barcode-directory (there must be a line "barcodedir=xxxxxxx,"; dont forget the comma)
<li>In the barcode-directory ($BSE/lib/barcode/xxxxxx; xxxxx = name of the barcode-Directory)
create the shellscript (Name type95)
</ul>
<p><p>
<h2>Report-Script :</h2>
Code:
|******************************************************************************
|* tdsqljo07 VRC B40C c4 entw
|* mehrere Seiten und Seite von
|* bj_104_a
|* 15.07.99 [14:05]
|******************************************************************************
declaration:
long int.unique | unique number (internal)
domain tcmcs.str8 int.unique.s
before.program:
long fp
long ok
string number(8)
| Get unique number
fp = seq.open(bse.tmp.dir$() & "/printing/unique.dat","r")
int.unique = 0
if fp > 0 then
if seq.gets(number,8,fp) = 0 then
int.unique = lval(number)
endif
seq.close(fp)
endif
| Write new Unique number
int.unique = int.unique + 1
fp = seq.open(bse.tmp.dir$() & "/printing/unique.dat","w")
if fp > 0 then
seq.puts(edit$(int.unique,"ZZZZZZZ9"),fp)
seq.close(fp)
endif
| Unique Number as string for printing
int.unique.s = edit$(int.unique,"ZZZZZZZ9")
after.program:
long fp
fp = seq.open(bse.tmp.dir$() & "/printing/numbers.dat","a")
if fp > 0 then
seq.puts( edit$(int.unique,"ZZZZZZZ9")&
":" &
edit$(lattr.pageno,"ZZZZZ9"),fp)
seq.close(fp)
endif
<p><p>
<h2>Shell-Script</h2>
Code:
#!/bin/sh
#******************************************************************************
#
# File : type95
#
# jb : Print "Page of"
#******************************************************************************
# get unique number out of the printing string (8 Bytes)
unique="$1:"
# search the file with unique number for the string "Nr:xxxxxxxx"
tmpdat="`grep $unique $BSE_TMP/printing/numbers.dat`"
# get the column with the number of pages
tmpdat=`echo $tmpdat|cut -f2 -d:|head -1`
# merge the numer of pages in the spool-output
echo "$tmpdat\c"
# exit
exit 0
<hr>
I have to admit : I'm not very strong in shell-Scripting. For my Sun it works fine, but
I suppose for other UNIXES you have to change something on the script. I'm sure someone
could do this script in a better way.
<hr>
Make sure, that the shell-Script is executable !!
<p>
Make sure, that the 2 ASCII-Files in the directory "printing"
(and the directory itself) are accessible (UNIX-rights)
<p>
In case of error : Check the logfile ($BSE/log/log.filter6.1)
<p><hr><p>
The number for uniqueness ist 8 digits long, so I dont think, there will a be
a problem, but feel free to increment the size
<p>
Clear the file with the page numbers every month (or every weekend).
<hr>
<address>
Jo Büche<br>
Baan & Schuler GmbH<br>
jbueche@baan-schuler.com
</address>