Compiling Source Code

In Visual FoxPro, you can compile Visual FoxPro source into run-time files created with either vfp7r.dll or vfp7t.dll. In prior versions of Visual FoxPro, you had to use macro substitution or expression evaluation for each line in order to execute code generated at run time. This process was not always optimal because of the complexities of executing large blocks of code and the performance penalty incurred using the macro operator &, or the EVALUATE( ) function.

The COMPILE command is now enabled in the run time so that your applications can generate and compile a program (.prg) file. You can use the STRTOFILE( ) function to output your code to a program file. Run time compilation works with all files supported by the COMPILE command including programs, forms, classes, labels, reports and databases.

There are a few differences between the compiler in the development product and in the run time:

  • The "?" switch of the COMPILE command has been disabled for run time since unattended automation servers (.dlls) do not allow modes involving user input.

  • The SET DEVELOPMENT command has no effect in the run time.

    With the full product, SET DEVELOPMENT causes Visual FoxPro to compare the creation date and time of a program with those of its compiled object file when the program is run. If SET DEVELOPMENT is set ON, the latest version is always executed – out-of-date programs are automatically recompiled. In the run time, you must explicitly call the COMPILE command to recompile source. This means that calling the DO command in your run time will never cause the PRG file to be recompiled. Also, with the run time, the DO command ignores the file extension and looks for a file with an .fxp extension, even if you specify a .prg.

See Also

Early (vtable) and Late (IDispatch) Binding | Interoperability and the Internet | Scalability and Multithreading | Visual FoxPro Run-Time Libraries