JavaScript Editor js editor     Web development 



Main Page

Compiles one or more specified source files and creates an object file for each source file. There are two versions of the syntax.

COMPILE [DATABASE | FORM | CLASSLIB | LABEL | REPORT] cFileName | cFileSkeleton | ? [ALL]
COMPILE cFileName | cFileSkeleton | ? [ENCRYPT] [NODEBUG] [AS nCodePage]

Parameters

DATABASE


Compiles one or more database (.dbc) files specified by cFileName or cFileSkeleton. Choosing DATABASE compiles source code for stored procedures that are saved with the database and stores it in an additional memo field. You can use the DATABASE option to compile stored procedures outside the Database Designer.
Note:
COMPILE DATABASE packs memo fields in the database memo file (.dct) to remove unused space from the memo file. Records marked for deletion in the database table are not removed from the table.

FORM


Compiles one or more form definition files (.scx) specified by cFileName or cFileSkeleton. Choosing FORM compiles source code for the data environment that is saved with the form and stores in an additional memo field. Visual FoxPro automatically compiles forms when they are saved in the Form Designer. You can use the FORM option to compile a form outside the Form Designer.
Note:
Form source code is stored in memo fields in the Form table. COMPILE FORM compiles the memo fields into object code and stores it in an additional memo field. Visual FoxPro executes the object code in the additional memo field when you use the DO FORM command. For more information, see DO FORM Command.

CLASSLIB


Compiles one or more visual class library (.vcx) files specified by cFileName or cFileSkeleton. Source code for a visual class library is stored in memo fields in the visual class library table. Choosing CLASSLIB compiles the memo fields into object code and stores it in an additional memo field.
LABEL


Compiles one or more label definition files (.lbx) specified by cFileName or cFileSkeleton. Choosing LABEL compiles source code for the data environment saved with the label file and stores it in an additional memo field.
REPORT


Compiles one or more report definition files (.frx) specified by cFileName or cFileSkeleton. Choosing REPORT compiles source code for the data environment saved with the report file and stores it in an additional memo field.
cFileName


Specifies the target file to compile. If you specify one of the listed options, the following table describes the values for cFileName that correspond to the option you choose.

Option cFileName

DATABASE

Name of the database containing the stored procedures to compile.

You can compile stored procedures in a database that is not open.

FORM

Name of the form to compile.

CLASSLIB

Name of the class library to compile.

LABEL

Name of the report to compile.

REPORT

Name of the report to compile.

If you do not specify one of the listed options, such as FORM or REPORT, the following list shows other files you can specify for cFileName.
  • Program (.prg)

  • Form (.spr)

  • Menu (.mpr)

  • Query (.qpr)

  • Format (.fmt)

cFileSkeleton


Specifies a set or subset of files that match a file skeleton that can contain wildcard characters such as an asterisk (*) or question mark (?). For example, to compile all database files that begin with the letter A, use the following command:
В Copy Code
COMPILE DATABASE A*
To compile all program files that have the .prg file name extension in the current directory or folder, use the following command:
В Copy Code
COMPILE *.PRG
?


Displays the Compile dialog box so you can browse and choose a file to compile.
ALL


For older cross-platform report (.frx) and label (.lbx) files, compiles all records for all Visual FoxPro platforms in the form table and is available only for the REPORT and LABEL options. If you omit ALL, only records for the current Visual FoxPro platform are compiled. For example, suppose you have an .frx file containing only Windows and Macintosh records. When executing the COMPILE command on a computer with Windows, omitting ALL compiles only Windows records.
ENCRYPT


Encrypts compiled Visual FoxPro program files and is not available when using the DATABASE, FORM, CLASSLIB, LABEL, and REPORT options. ENCRYPT prevents access to the original source programs. For additional source code protection, always include this option when compiling programs intended for distribution.
NODEBUG


Reduces the size of the compiled file by two bytes per source file line and is not available when using the DATABASE, FORM, CLASSLIB, LABEL, and REPORT options. The two bytes reduced in the compiled file are a reference to the corresponding line in the source file. Removing these two bytes does not affect the program's performance, but it does reduce the compiled file size and conserves disk space.
Note:
When you include NODEBUG, you cannot view execution of the program in the Trace window or return the source code for a line that causes an error by using MESSAGE(1). For more information, see MESSAGE( ) Function.

AS nCodePage


Specifies the code page for which a program file is compiled and is not available when using the DATABASE, FORM, CLASSLIB, LABEL, and REPORT options. The compilation code page you specify overrides the global compilation code page specified with SET CPCOMPILE.

Remarks

Visual FoxPro executes only object files, so if a source file has not been compiled, it is automatically compiled into an object file when you run the program. The source file remains unchanged. A separate compiled object file is created with the same root name as the source file, but with a different extension. The following table lists example source file extensions and compiled file extensions for each file type.

File type Source extension Compiled extension

Program file

PRG

FXP

Menu code

MPR

MPX

Query

QPR

QPX

Format

FMT

PRX

The compiler detects any syntax errors in the source file. If SET LOGERRORS is set to ON when the file is compiled, Visual FoxPro saves compilation error messages to a text file. The error log file has the same root name as the compiled file and has an .err file name extension. If SET LOGERRORS is set to OFF, the error log file is not created. For more information, see SET LOGERRORS Command.

If a form has an #INCLUDE header (.h) file, and the .h file is moved from its original directory, a compilation error occurs and is listed in the error log (.err) file. You can run the form, but if you modify it, you cannot save it until you correct the path to the .h file.

To correct the path for a moved header (.h) file
  1. Open the form using the MODIFY FORM command.

  2. On the Form menu, choose IncludeFile.

  3. In the IncludeFile dialog box, browse to or type the new path for the .h file.

For more information, see #INCLUDE Preprocessor Directive, MODIFY FORM Command, and Include File Dialog Box.

Examples

The following example uses CLOSE DATABASES to close all open databases and uses COMPILE DATABASE to compile all the stored procedures in the Visual FoxPro sample database, TestData.dbc.

В Copy Code
CLOSE DATABASES
COMPILE DATABASE (HOME(2) + 'Data\TestData')

See Also



JavaScript Editor js editor     Web development