Compiles one or more source files and creates an object file for each source file.
COMPILE [?] [CLASSLIB | LABEL | REPORT] FileName | FileSkeleton
COMPILE FileName | FileSkeleton | ? [ENCRYPT] [NODEBUG] [AS nCodePage]
- Specifies that the file to compile is a visual class library (.vcx). Visual class library source code is stored in memo fields in the visual class library table. COMPILE CLASSLIB compiles these memo fields into object code that is stored in an additional memo field.
- Specifies that the file to compile is a label definition file (.lbx). Source code for the data environment saved with the label definition file is compiled and stored in an additional memo field.
- Specifies that the file to compile is a report definition file (.frx). Source code for the data environment saved with the report definition file is compiled and stored in an additional memo field.
- FileName | FileSkeleton
- Specifies for compilation a single file FileName or a set of files that match a file skeleton FileSkeleton containing wildcards such as * and ?. For example, to compile all program files with the extension .prg in the current directory or folder, issue COMPILE *.PRG.
- Displays the Compile dialog box, allowing you to choose a file to compile.
- Encrypts your compiled Visual FoxPro programs. Cannot be used with the CLASSLIB, LABEL, and REPORT keywords. This prevents any access to your original source programs. For additional source code protection, always include this option when compiling programs intended for distribution.
- Reduces the size of your compiled file by two bytes per source file line. Cannot be used with the CLASSLIB, LABEL, and REPORT keywords. These two bytes in the compiled file are a reference to the corresponding line in the source file. Removing these two bytes doesn't affect the program's performance, but it does reduce your compiled file size, and conserves disk space.
When you include NODEBUG, you cannot view a program's execution in the Trace window or use MESSAGE(1) to return the source code for a line that causes an error.
- AS nCodePage
- Specifies the code page for which the program is compiled. Cannot be used with the CLASSLIB, LABEL, and REPORT keywords. The compilation code page you specify with this clause overrides the global compilation code page specified with SET CPCOMPILE.
Visual FoxPro executes only object files, so if a source file hasn't been compiled it is automatically compiled when you run the program. The source file remains unchanged. A separate compiled file is created with the same root name as the source file, but with a different extension. The following table lists the source and compiled file extensions for each file type:
|File type||Source extension||Compiled extension|
The compiler detects any syntax errors in the source file. Compilation error messages are saved to a text file if SET LOGERRORS is ON when the file is compiled. The error log file has the same root name as the compiled file, and has an .err extension. If SET LOGERRORS is OFF, the error log file isn't created.
#DEFINE ... #UNDEF Preprocessor Directive | #IF ... #ENDIF Preprocessor Directive | #IFDEF|#IFNDEF ... #ENDIF Preprocessor Directive | #INCLUDE | BUILD PROJECT | COMPILE DATABASE Command | COMPILE FORM Command BUILD APP | MODIFY COMMAND | MODIFY PROJECT | SET CPCOMPILE | SET LOGERRORS