Quick & Dirty Hook Program
Most of the time, we need hook(s) to allow custom program to be run before/after certain process. There are many ways to accomplish it in VFP, ex. add-in manager (as class browser does), EXECSCRIPT() to run code stored in memo field or external app.
However, we need some time to design and implement add-in manager. Also, EXECSCRIPT() function only available in VFP8 and later. A quick and dirty way to do this is to create an external .app and call it using DO statement.
IF FILE("premyprcs.app")The downside of doing this is we can't return value from external .app to report status. The workaround is, pass an additional parameter by reference and assign the return value to it within the external .app.
DO ("premyprcs") WITH para1, para2, ...
ENDIF
BTW, remember to use DO ("premyprcs") instead of DO premyprcs to prevent VFP project manager to search for the external .app file and return error during compilation.
2 Comments:
The params of the DO command are BY REFERENCE per default. Functions are BY VALUE, but DO is BY REFERENCE. Therefor, any parameter you use is automatically two-way.
Thank you for comment.
What I meant is we have no way to :
DO ("mypremyprcs.app") WITH para1, para2 TO lnRetval
Instead, we got to
DO ("mypremyprcs.app") WITH para1, para2, lnRetval
IF lnRetVal < 0
*--Do whatever
ENDIF
Post a Comment
<< Home