AfterDropTable

Compile, Set LogErrors, Set("LogErrors")

COMPILE converts your source code into executable object code, checking for errors along the way. SET LOGERRORS determines whether a log file containing the errors is created.

Usage

COMPILE FileSkel [ ENCRYPT ] [ NODEBUG ] [ AS nCodePage ] SET LOGERRORS ON | OFF lLogOn = SET( "LOGERRORS" )
If you're like us, you'll rarely issue the COMPILE command from the Command Window. Between it being on the menu and the Project Manager doing it for us, it's just not that necessary to do very often. But, once in a while, there's a reason to compile a particular file or a group of files. The ENCRYPT and NODEBUG clauses correspond to the Encrypted and Debug Info check boxes in the Project Information dialog (though the latter is negative in the command and positive in the dialog).

VFP 6 Service Pack 3 added the ability to compile a file in a runtime environment. Why would you want to do that? In a word, scripting. Sometimes, you can't write the code for the necessary behavior of an application in advance. Perhaps the user wants to customize the behavior. Perhaps the structure of the code depends on environmental things. The COMPILE command allows you to create and execute code in a runtime environment. For example, you might store the code in a memo field in a table, you may generate it using textmerge commands, or you might allow the user to type it into an edit box on a form. Regardless of how the code is created, you must compile it before you can execute it. See the example for one potential use: providing a Command Window emulator in a runtime environment.

VFP 7 enhanced this command further: COMPILE now respects the setting of SET NOTIFY, so the user won't see a "compiling" message on the screen when a large file is compiled. However, VFP 7 also made COMPILE less important in a runtime environment, at least for scripting purposes, by adding the EXECSCRIPT() function to the language. See the topic for this function for details on how it works and when you might use it.

By default, when you compile a program and errors are found, an ERR file is created, which contains information about the errors. If you SET LOGERRORS OFF, no such file is created. We can't imagine why anyone would ever turn that setting off. When you compile in a runtime environment, this is the only way to check that the compile was successful.

Example

* This code would be found in the Click method of an Execute * button on a Command Window emulator form. It assumes that * edtCode is the name of an edit box on the form into which * the user types the code to execute.   * Copy the code to a temporary file, then compile it, execute * it, and erase the temporary PRG and FXP files. lcTempPRG = SYS(2015) STRTOFILE(Thisform.edtCode.Value, lcTempPRG) COMPILE (lcTempPRG) DO (lcTempPRG) ERASE (lcTempPRG) ERASE FORCEEXT(lcTempPRG, 'FXP')

See Also

Build App, Build EXE, Build Project, Compile Classlib, Compile Database, Compile Form, Compile Label, Compile Report, ExecScript(), Set Notify


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