QueryAddFile, QueryModifyFile, QueryNewFile, QueryRemoveFile, QueryRunFile

These events are among the things that make project hooks so powerful. They fire just before the indicated action occurs and give you a chance to meddle.

Usage

phkProjectHook.QueryAddFile( cFileName )
phkProjectHook.QueryModifyFile( filFile [, cClassName ] )
phkProjectHook.QueryNewFile( cFileType )
phkProjectHook.QueryRemoveFile( filFile 
                                [, cClassName | lDeleteIt ] )
phkProjectHook.QueryRunFile( filFile )

Parameter

Value

Meaning

cFileName

Character

The name of the file being added, including the path.

filFile

File Object

An object reference to the file affected.

cClassName

Character

The class to be modified or removed from the class library. Passed only if filFile is a class library and, for QueryRemoveFile, only if an individual class is selected for removal, not the whole class library.

cFileType

Character

A single character indicating the type of file being created. See Help for the list.

lDeleteIt

Logical

Indicates whether the file is also being deleted from the disk.


These are some of the events that give project hooks their hook. You can do whatever you want before the specified action takes place, including prevent it. Among the things you might want to do are log the action or confirm it with the user (though we'd hate that, if it were us). To prevent the action, put NODEFAULT in the code. If you're thinking of doing so, remember that a developer-user might be a little puzzled to click Modify and not have an editor open up, so save this one for when it really makes sense. When is that? One thing that comes to mind is when the developer chooses Run and the file really needs a lot of other stuff in place in order to run properly. Rather than running it and making a mess, you might want to tell the developer what needs to happen first and abort the run.The other place where stopping an action in its tracks might make sense is when you're doing lots of project manipulation programmatically. You can call the project/file method to do something, and let the QueryWhateverFile method figure out whether it really ought to happen.In the VFP 6 version of this book, we complained that no hook fired when the user added a new file to the project. Microsoft listened, and in VFP 7, added the QueryNewFile event. This event fires when the user chooses New in the Project Manager, passing a character that indicates the type of file being created.

Example

* Log additions to a project.
* Assume that the log table is open, perhaps opened
* by the project hook's Init event.
PROCEDURE QueryAddFile
LPARAMETERS cFileName
 
INSERT INTO Log VALUES ("Add",cFileName,DATETIME())
RETURN

See Also

Add, AfterBuild, BeforeBuild, Modify, ProjectHook, Remove, Run Method


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .