Wiki Home

VFP Compile Command

Namespace: VFP
Explain the uses and vagaries of the VFP COMPILE command

From the VFP Help:
COMPILE [CLASSLIB | LABEL | REPORT] FileName | FileSkeleton | ?
  [AS nCodePage]

Basically, the purpose of the compile command is to take Visual FoxPro Source code and turn it into compiled code, be that in an .FXP file or in an ObjCode memo field of a Class libarary (.VCX/VCT), label file (.LBX/LBT) or report file (.FRX/FRT).

I have only one file starting with "util" in the CurDir() and that file is UTIL.PRG. However, when I type "COMPILE UTIL" at the command prompt, it did compile (displayed "1 File, 0 Errors" in the status bar) but no UTIL.FXP was generated anywhere on my drive (I was on a disconnected notebook... no other drives to think about). But Then, when I typed "COMPILE UTIL.PRG" it did compile (displayed "1 File, 0 Errors" in the status bar) and it DID create a UTIL.FXP file. What Gives? Anybody see anything like this? -- wgcs It worked fine for me... Steven Black
I made some progress... I had a tool loaded ( ) which happens to also use my UTIL.PRG routines. It has UTIL.PRG internal to the .APP file and had a SET PROCEDURE UTIL set to it. SET("PROC") only showed "UTIL.FXP" as the loaded procedure file (ie: no path). And if I issued "COMPILE UTIL" it, as above, seemed to compile but produced no FXP file. -- ?wgcs

Starting from the SP3 for VFP 6 COMPILE command for PRG files works in run-time with installation of VFP run-time libraries only. The example of use is in thous servers that provide business rules in the database. Storing business rules in the database and changing them on th fly affecting each client by these rules is very good feature. It might be implemented only using this command to compile business code from database.

This is very handy command, but the disadvantage is that it displays a compile progress window. The workarouns of this are following:
1. Make a FVP.Application COM object call and let it compile program for you. This will never display an message or window to users, but works slow unless you run this COM object from your application start, taking some memory.
2. Use activeX control that will make a windows hook to prohibit any window opening for duration of some command. We made such approach and it works very well.

-- Vlad Grynchyshyn
Another issue (probably related to the lack of an .FXP file above) is that if VFP has cached a class definition from the file in memory, you get the error 1184 - File cannot be closed because outstanding references exist. This is an issue when trying to update a running application. You must clear the class definitions defined in the (.FXP) file from memory before you compile the (.PRG) file.

You can do this with the CLEAR CLASS xyz command, where xyz is the name of the class. The class definition will be removed from memory provided it is not in use. A class definition can be in use because an object of that class exists, or because a subclass definition is cached.

Unfortunately, there seems to be no way to clear all class definitions from memory, nor is there really a way to write one without knowing your class hierarchy, since you can not get information on which class definitions are cached.

Contributors: wgcs
Category VFP Commands
( Topic last updated: 2003.01.03 03:50:08 PM )