Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
My own function
Message
From
14/01/1999 07:48:46
 
 
To
14/01/1999 07:22:09
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00175828
Message ID:
00175832
Views:
27
>I want create my own function.
>I used Set Procedure To , but I can't
>call it from report.
>How I can do this?

It's pretty straightforward. You need to create a .PRG file that contains your function; the value returned by your function will be displayed by the report.

For example, suppose I want a function that returns the area of a circle of a radius specified by some field value. I could create a .PRG as follows:

* Function CircleArea.PRG
LPARAMETER tnRadius
RETURN (PI() * tnRadius * tnRadius)

Within my report, I could then use the function CircleArea anywhere I wanted to put a numeric expression, as long as VFP could find CircleArea.PRG. If the function is a .PRG in and of itself, there's no need for SET PROCEDURE TO. SET PROCEDURE TO is only needed if the procedure is one of several procedures or functions within a single .PRG file - SET PROCEDURE TO makes VFP search the .PRG for PROCEDURE and FUNCTION names matching unresolved function names. For example, you might have a procedure library MyProcLib.PRG:

*MyProcLib.PRG
FUNCTION CircleArea
LPARAMETER tnRadius
RETURN (PI() * tnRadius * tnRadius)

FUNCTION OneThird
LPARAMETER tnNumTODivide
RETURN (tnNumToDivide/3)

* etc...

Now, SET PROCEDURE TO MyProcLib would make the FUNCTIONS CircleArea() and OneThird() contained in MyProcLib.PRG visible to VFP.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform