...SAY - BMP and OLE Objects

BeforeBuild, AfterBuild

These project hook events, as their names imply, fire before and after the project's Build method is called, whether the call comes from the interface or in code.

Usage

phkProjectHook.BeforeBuild( [ cResultFile ] [, nBuildType ]                            [, lRebuildAll ] [, lShowErrors ]                            [, lRegenerateIds ] ) phkProjectHook.AfterBuild( nError )
BeforeBuild receives exactly the same parameters as Build, with one difference. BeforeBuild gets them by reference and can change them. The changed values are what actually get passed on to Build. This means a project hook can totally hijack the build process and do whatever it wants, regardless of what the developer-user does interactively. (Of course, generally, changing a user's actions behind the scenes is frowned upon, except when it protects the user from himself.)

AfterBuild is a lot simpler and a lot less powerful. It receives a single parameter, indicating whether or not an error occurred that prevented the build from completing. We're not sure where the error numbers come from, though.

As with the other project hook events, you can use these either to log actions or to change them. NODEFAULT in BeforeBuild prevents the project from being built. NODEFAULT in AfterBuild is pointless—there is no default behavior.

Example

* We might use BeforeBuild to check whether there  * seems to be enough room for whatever we're building. PROCEDURE BeforeBuild LPARAMETERS cOutputName, nBuildAction, lRebuildAll, ;             lShowErrors, lBuildNewGuids   LOCAL cOutDrive, nSpace, nProjSize, nSizeNeeded cOutDrive = JustDrive(cOutputName) nSpace = DISKSPACE(cOutDrive)   * Perhaps we base expected need on project size.  * For project size, we'll use rough justice based on the number  * of files in the project. The average file size of 10000 is  * picked at random and needs to be tuned. You could scan the * Project object's File collection and supply the File's Name * to ADIR() and sum them up. Don't forget to add in the runtime!   * The next line assumes that the project hook's Init method * grabs a reference to the project and stores it in * a property called oProject.   nProjSize = This.oProject.Files.Count * 10000 IF nSpace < nProjSize      LOCAL cBuildType, nResult      * Figure out the type of build.    DO CASE    CASE nBuildAction = 1       cBuildType = "Project"    CASE nBuildAction = 2       cBuildType = "App"    CASE nBuildAction = 3       cBuildType = "Exe"    CASE nBuildAction = 4       cBuildType = "DLL"    CASE nBuildAction = 5    ENDCASE      nResult = MESSAGEBOX("Drive " + cOutDrive + ;                " doesn't appear to have enough free space " + ;                " to build this project. Proceed anyway?", ;                MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2, ;                "Build "+cBuildType)    IF nResult = IDNO       NODEFAULT    ENDIF ENDIF   RETURN

See Also

Build, Project, ProjectHook


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net