6

The LA Fox Developer Newsletter
February 1995
Reporting With Variable
Number of Copies
by Toni Mas of S.Quirze del Vallês,
BARCELONA SPAIN.

A lot of times, within an aplication, we must launch reports with a number of copies and we all know that running on Windows each ‘report ...‘ instruction has a performance cost. Due to that fact I’ve been trying different ways to make the reports with copies appearing as pages for Windows to launch an unique ‘report’ command and have better performance. This problem is still worse when the number of copies of a document I variable depending on each record of our database.

Let’s see an example:

I’ve got a 'Customer' table where each costumer has different number of copies per invoice to be sent. In the other hand I’ve got a header invoice file called ‘head_mv’ and another file containing several lines per each header called ‘Iines’.When we run the invoice report we must send different number of copies each invoice depending on its customer.We cannot modify the ‘system.ini’ file ‘cause it must be different each time and it’ll be a patch.

I’ve written this procedure that takes from the calling program the followind data parameters:

document
Number of the document
copies
* Number of copies to print
Iloc * A string that contains 'Printer' or ‘Screen’ to
*
select the output.
Then I propose to doing it this way (it works for me):

I. .We create a cursor that will contain a record for each copie

and also the number of the invoice (or document).
create cursor repeat (invoice N(1O),numcopia N(2))

for copia 0 to coples7F
insert into repeat (invoice,numcopia) values (document,copia) next

2.We create a sql-select where the ‘lines’ file is the main file and has a relation with its header through its number of document and also with the ‘repeat’ file in order to generate an exact line per copy. The results must be ordered by the element ‘numcopia’.

Select llnes.*,head_inv.*, repeat.numcopia from; lines,headjnv,repeat
where header_inv.document lines.document and;
repeat.lnvoice document order by repeat.numcopia into cursor llistat


(Con’t, next column)
Special Big Announcement
The LA Fox Developer’s Group has entered into an agreement with Macmillan Computer Publishing. LA Fox members can now purchase all Macmillan Computer Publishing titles at a discount of 30% off retail pricing.

Macmillan owns the following publishers:
Que
New Riders Press
The Waite Group
Ziff-Davis
Sams/sams. net
Que Education & Training
Macmillan Technical Publishing
Hayden
Adobe Press
Borland Press
Lycos Press

With all these publishers and over 40% market share, Macmillan has the best books for computer technology.

To take advantage of this offer, you must be a member-in-good- standing (read current and paid-up) and have a credit card. You can receive our special account number and the 800 access number by calling me at 800/499-6237 or 714/375-3300, oremailinq me at CompuServe (72723,3422) or brlee@earthlink. net.

Reporting (Con't from previous column)

3.The cursor ‘Ilistat’ is the basis to build the report.That report must be grouped by repeat. Numcopia and must skip new page foreach.
4.We state


if Iloc’Screen’
report form preview
else
report form noco to printer
endif

That’s it!.Now we have an unique ‘report’ command and Fox windows will show us the report screen telling the number of copies insted of appearing once for each copy or the command ‘report...’

I’m sure this snipet’ll help a lot of people as well as me. By the way I’m looking forward to receiving some comments to enhance it or to solve any questions to whoever has them.


(Ed. Note: Toni may be reached attmas@valser.es.]
Page 6

6