Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

BeforeAppendProc, AfterAppendProc, BeforeCopyProc, AfterCopyProc, BeforeModifyProc, AfterModifyProc

These Database Events fire when the stored procedures of a database are manipulated in some way: appended from a file, copied to a file, or modified in a code window.

Usage

PROCEDURE DBC_BeforeAppendProc( cFileName, nCodePage,
                                lOverwrite )

PROCEDURE DBC_AfterAppendProc( cFileName, nCodePage,
                               lOverwrite )

PROCEDURE DBC_BeforeCopyProc( cFileName, nCodePage, lAdditive )

PROCEDURE DBC_AfterCopyProc( cFileName, nCodePage, lAdditive )

PROCEDURE DBC_BeforeModifyProc()

PROCEDURE DBC_AfterModifyProc( lChanged )

Parameter

Value

Meaning

cFileName

Character

The name of the file that procedures are appended from or copied to.

nCodePage

Numeric

The codepage for the file. VFP will automatically convert from that codepage to the codepage for stored procedures when appending procedures or vice versa when copying procedures.

lOverwrite

Logical

Indicates whether the OVERWRITE clause was included in the APPEND PROCEDURES command.

lAdditive

Logical

Indicates whether the ADDITIVE clause was included in the COPY PROCEDURES command.

lChanged

Logical

Indicates whether the stored procedures were changed.

As is the case with other before-and-after pairs of events, you can prevent the action from taking place by returning .F. in the Before events, while the After events simply receive notification that something happened. The Before events of these three sets, along with BeforeDBSetProp, are key to preventing someone from seeing or altering your stored procedure code; see “Database Events” for details.

Example

* Prevent everyone except developers from seeing or altering the
* stored procedures. Store the current stored procedures in a
* "before" snapshot in case we want to restore them later.

PROCEDURE DBC_BeforeAppendProc(cFileName, nCodePage, lOverwrite)
LOCAL llOK
llOK = IsDeveloper()
IF llOK
    DO SaveProcs
ENDIF llOK
RETURN llOK

PROCEDURE DBC_BeforeCopyProc(cFileName, nCodePage, lAdditive)
RETURN IsDeveloper()

PROCEDURE DBC_BeforeModifyProc()
LOCAL llOK
llOK = IsDeveloper()
IF llOK
    DO SaveProcs
ENDIF llOK
RETURN llOK

* Log when someone changes the stored procedures.

PROCEDURE DBC_AfterAppendProc(cFileName, nCodePage, lOverwrite)
DO LogDBCChange WITH IIF(lOverwrite, "Overwritten by ", ;
    "Appended from ") + cFileName

PROCEDURE DBC_AfterModifyProc(lChanged)
IF lChanged
    DO LogDBCChange WITH "Modified"
ENDIF lChanged

See Also

Append Procedures, BeforeDBSetProp, ModifyData, Copy Procedures, Database Events, Modify Procedure