COMPLETED()

BeforeValidateData, AfterValidateData, PackData

The first two database events fire when a database is validated using VALIDATE DATABASE. The last one fires when it's packed, either programmatically with PACK DATABASE or visually by choosing "Clean Up Database" from the Database menu.

Usage

PROCEDURE DBC_BeforeValidateData( lRecover, lNoConsole, lPrint,                                   lFile [, cFileName ] )   PROCEDURE DBC_AfterValidateData( lRecover, lNoConsole, lPrint,                                  lFile [, cFileName ] )

Parameter

Value

Meaning

lRecover

Logical

Indicates whether the RECOVER clause was specified.

lNoConsole

Logical

Indicates whether the NOCONSOLE clause was used.

lPrint

Logical

Indicates whether the TO PRINTER clause was used.

lFile

Logical

Indicates whether the TO FILE clause was specified.

cFileName

Character

The name of the file output is directed to.


If the TO FILE clause isn't specified, the cFileName parameter isn't passed (PCOUNT() returns 4), but be sure to include it in the parameter list or you'll get a "Must specify additional parameters" error if TO FILE is used.


As is the case with other before-and-after pairs of events, you can prevent a database from being validated by returning .F. in the BeforeValidateData event, while the AfterValidateData event simply receives notification that something happened.

BeforeValidateData and AfterValidateData don't fire when the VALIDATE clause is used with the OPEN DATABASE command. However, the OpenData event receives .T. for the lValidate parameter, so if you need to do something whenever the database is validated, you could call the same routine BeforeValidateData does when OpenData receives .T. for that parameter's value. This is another example that proves the rule "Events call methods."


Example

* This code goes in the stored procedures of a database.   PROCEDURE DBC_BeforeValidateData(lRecover, lNoConsole, lPrint, ;     lFile, cFileName) WAIT WINDOW PROGRAM() + CHR(13) + ;     'lRecover: ' + TRANSFORM(lRecover) + CHR(13) + ;     'lNoConsole: ' + TRANSFORM(lNoConsole) + CHR(13) + ;     'lPrint: ' + TRANSFORM(lPrint) + CHR(13) + ;     'lFile: ' + TRANSFORM(lFile) + CHR(13) + ;     'cFileName: ' + TRANSFORM(cFileName)   PROCEDURE DBC_AfterValidateData(lRecover, lNoConsole, lPrint, ;     lFile, cFileName) WAIT WINDOW PROGRAM() + CHR(13) + ;     'lRecover: ' + TRANSFORM(lRecover) + CHR(13) + ;     'lNoConsole: ' + TRANSFORM(lNoConsole) + CHR(13) + ;     'lPrint: ' + TRANSFORM(lPrint) + CHR(13) + ;     'lFile: ' + TRANSFORM(lFile) + CHR(13) + ;     'cFileName: ' + TRANSFORM(cFileName)   * End of stored procedures.     * Validate a database.   OPEN DATABASE TestData EXCLUSIVE VALIDATE DATABASE RECOVER TO PRINT

Usage

PROCEDURE DBC_PackData()
There are no before and after events for packing a database; the PackData event fires before packing occurs, so return .F. to prevent packing from taking place (you'll get a "file access denied" error in that case). This might be an issue if you need to do something after a database is packed, although we can't really think of anything useful you'd want to do.

As explained in the topic for PACK DATABASE, you can use the PACK command to pack a database if you open it as a table. However, since it isn't open as a database when you do that, the PackData event doesn't fire.


Example

* This code goes in the stored procedures of a database.   PROCEDURE DBC_PackData() WAIT WINDOW PROGRAM()   * End of stored procedures.     * Pack a database.   OPEN DATABASE TestData EXCLUSIVE PACK DATABASE
 

See Also

Database Events, Open Database, OpenData, Pack, Pack Database, Validate Database


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