fwCompile Object

Description

The fwCompile object provides functionality that enables compilation of FWX and PRG scripts. It's primary use is for performing compilation when FoxWeb is configured to run with the VFP run-time DLL, which prevents it from compiling scripts automatically. The easiest way to compile scripts on your server if you are using the VFP run-time DLL is by calling the internal fwAdmin script from a Web browser. The fwCompile object is exposed and documented in case you need additional control over the scope, timing and other details of the compilation process.

Properties

DisplayErrors Controls whether compilation errors are written to the HTML output that gets returned to the browser.
DisplayFileList Controls whether the list of files being compiled gets written to the HTML output that gets returned to the browser.
Encrypt Controls whether compiled files are encrypted. Corresponds to the ENCRYPT clause of VFP's COMPILE command.
Errors This property points to an Errors object, holding any errors encountered during the compilation process.
ErrorStatusPrefix Holds a text string that gets sent to the browser before each error message when the DisplayErrors property is set to True.
ErrorStatusSuffix Holds a text string that gets sent to the browser after each error message when the DisplayErrors property is set to True.
FileCount Returns the number of files processed by the CompileBatch method.
FileStatusPrefix Holds a text string that gets sent to the browser before each file name when the DisplayFileList property is set to True.
FileStatusSuffix Holds a text string that gets sent to the browser after each file name when the DisplayFileList property is set to True.
Force Forces the Compile and CompileBatch methods to compile files even if the script source is older than the corresponding FXP file.
HidePaths Controls whether full file paths are included in the HTML output that gets returned to the browser when the DisplayFileList property is set to True.

Methods

Compile Compiles a single file.
CompileBatch Compiles whole directory trees.

DisplayErrors Property

Description

The DisplayErrors property controls whether compilation errors are written to the HTML output that gets returned to the browser. This property, along with ErrorStatusPrefix and ErrorStatusSuffix affect the display of error messages during calls to the Compile and CompileBatch methods. Setting this property to False suppresses output of errors during compilation. Your scripts can still use the Errors property to handle, log and display compilation errors. The default value for this property is True.


DisplayFileList Property

Description

The DisplayFileList property controls whether the list of files being processed by the CompileBatch methods is written to the HTML output that gets returned to the browser. This property, along with FileStatusPrefix, FileStatusSuffix and HidePaths affect the display of files during compilation. Setting this property to False suppresses output of the file list. The default value for this property is True.


Encrypt Property

Description

The Encrypt property determines whether files are encrypted during compilation and corresponds to the ENCRYPT clause of VFP's COMPILE command. Encryption prevents access to your original source programs. For additional source code protection, always include this option when compiling programs intended for distribution. The default value for this property is False.


Errors Property

Description

The Errors property points to an Errors object, holding any errors encountered during the compilation process. This property is read-only.


ErrorStatusPrefix Property

Description

The ErrorStatusPrefix property contains a string of characters that gets written to the HTML output before each error message if the DisplayErrors property is True. The default value of this property is an empty string.


ErrorStatusSuffix Property

Description

The ErrorStatusSuffix property contains a string of characters that gets written to the HTML output after each error message if the DisplayErrors property is True. The default value of this property is "<BR>" + CHR(13) + CHR(10).


FileCount Property

Description

The FileCount property contains the number of files successfully processed by the last call to the CompileBatch method. This property is read-only.


FileStatusPrefix Property

Description

The FileStatusPrefix property contains a string of characters that gets written to the HTML output before each file name if the DisplayFileList property is True. The default value of this property is an empty string.


FileStatusSuffix Property

Description

The FileStatusSuffix property contains a string of characters that gets written to the HTML output after each error message if the DisplayFileList property is True. The default value of this property is "<BR>" + CHR(13) + CHR(10).


Force Property

Description

If the Force property is set to True, the Compile and CompileBatch methods will compile files even if the script source is older than the corresponding FXP file. The default value for this property is False.


HidePaths Property

Description

Setting HidePaths to True enables the display of full file paths in the list of files sent back to the browser during batch compilation. The default value for this property is True.


Compile Method

Description

The fwCompile.Compile method compiles individual FWX and PRG scripts into FXP files in the same directory. FoxWeb automatically compiles PRG and FWX files if necessary before calling them either as a result of them being referenced in the URL, or during calls to the Server.Execute method. Moreover, FoxWeb automatically compiles PRG files that are called with the DO command, or are referenced in function calls, as long as it is not running with the VFP run-time DLL. However, there are other situations where it is sometimes desirable to be able to manually compile a script. One example is compilation of PRG files on a server that is using the VFP run-time DLL. Another example, is the need to force recompilation of scripts after an upgrade to a new version of VFP, by setting the Force property to True.

Syntax

fwCompile.Compile(cScriptName)

Parameters

cScriptName

Specifies the name and location of the script to be compiled.


CompileBatch Method

Description

The fwCompile.CompileBatch method compiles multiple FWX and PRG scripts that match the cFileSpec parameter. FoxWeb automatically compiles PRG and FWX files if necessary before calling them either as a result of them being referenced in the URL, or during calls to the Server.Execute method. Moreover, FoxWeb automatically compiles PRG files that are called with the DO command, or are referenced in function calls, as long as it is not running with the VFP run-time DLL. However, there are other situations where it is sometimes desirable to be able to manually compile a script. One example is compilation of PRG files on a server that is using the VFP run-time DLL. Another example, is the need to force recompilation of scripts after an upgrade to a new version of VFP, by setting the Force property to True.

Syntax

fwCompile.CompileBatch(cFileSpec[, lRecurse])

Parameters

cFileSpec

This argument specifies the file(s) to be compiled. It can point to a directory, or a file and can also contain the wildcard characters * and ?. A question mark represents a single character; an asterisk represents any number of characters. You can use any number of wildcards in any position within the file skeleton. You can specify a drive and/or directory to search in for matching file names. If you don't specify a drive and directory, CompileBatch looks for files matching cFileSpec in the current directory and in the locations specified in the PATH setting.

lRecurse

Optional parameter, specifying whether to compile scripts in subdirectories. The default value for this argument is False.

Example

<%
fwCompile.Force = .T.
fwCompile.Encrypt = .T.
fwCompile.HidePaths = .F.
fwCompile.ErrorStatusPrefix = '<font color="red">'
fwCompile.ErrorStatusSuffix = '</font></br>' + CHR(13) + CHR(10)
fwCompile.FileStatusPrefix = ''
fwCompile.FileStatusSuffix = '</br>' + CHR(13) + CHR(10)
Response.Buffer = .T.
fwCompile.CompileBatch(M.fw_RootPath, .T.)
Response.Write('<br>Total files compiled: ' + ;
    Server.ToString(fwCompile.FileCount) + LF ;
    + '<br>Total Errors: ' + Server.ToString(fwCompile.Errors.Count) + LF)
%>

© Aegis Group