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 ) |
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 |