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.

NoteNote

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.

NoteNote

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:

 CopyCode imageCopy 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:

 CopyCode imageCopy 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.

NoteNote

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.

Expand imageRemarks

Expand imageExamples

Expand imageSee Also