Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Pete Sass
 To: Luis
  Where is Luis?
Subject: RE: Using UDF in a Report
Thread ID: 16090 Message ID: 16094 # Views: 1 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Tuesday, October 08, 2002 11:19:00 PM         

> Hi:
> I'm creating a report and i wan't to sumarize a time field wich type is caracter, in my program i'm using the functions from Boudejin to operate times.
> What i wan't is to be able to use those functions in the report to calculate the total of a group.
> Pleas give an advice.
> Luis Navas
> For long you live and high you fly


Again I do not know exactly what you are doing, but including a UDF() in VFP report
writer is easy.
What you need to do is the following:
1. Code a seperate prg (myprg) that will take whatever values you want to calculate.
You may have to issue an Do While... some condition Enddo to obtain the
numeric calculations you are after.
In this prg you will need a memory variable that holds the calculations after they
are done for that particular group.
The last line of this prg will be:
RETURN mymemoryvariable (holding the summarized numeric calculations)
2. You can if you wish assign mymemorvariable as Public in the form or
what-ever prior to running the report. There are other ways........ as well.
3. On your report enter a field and have it called myprg()

When the report hits myprg() it will call the myprg.prg and perform the calculations
and return the value back into the report. Ensure if you are dealing with multiple
tables in the myprg store the original table to a memory variable using:
corigtble=dbf() as the first line of code in the prg
and set the table back to this original in the myprg.prg just prior to the
RETURN mymemoryvariable command.

You may also have to store the recno() of the table and set the pointer back
to it's original location in the myprg.prg before the RETURN mymemoryvariable command.

Hope this gives you some idea of how to use a UDF within the VFP report writer. I have done
what I can to explain without knowing you exact table structures in the report.
I am planning on my next article on report writer to have examples of various UDF in
VFP reports. Just have not had the time as yet !

Pete from the Great White North ! (Only in Canada, ay...) Over and Out ...


Using UDF in a Report Posted by Luis Navas @ 10/8/2002 10:53:39 PM
RE: Using UDF in a Report Posted by Pete Sass @ 10/8/2002 11:19:00 PM
RE: Using UDF in a Report Posted by Luis Navas @ 10/8/2002 11:35:20 PM
We never get mad at Foxite... Here to serve ! Posted by Pete Sass @ 10/8/2002 11:51:42 PM
ok thanks Posted by Luis Navas @ 10/9/2002 12:52:52 AM