Icon Defines

Elevate Web Builder supports basic compiler define functionality. Compiler defines are symbols used to conditionally include or exclude code in the compilation process, and can be tested at compile-time to make such a determination. Compiler defines are taken into account during the parsing phase of the compilation process.

Information Elevate Web Builder defines a special DESIGN symbol automatically during compilation. If the code is being compiled for design-time use in the component library, then the DESIGN symbol will be defined. If the code is being compiled for run-time use, then the DESIGN symbol will not be defined. Component developers can test for this special DESIGN symbol to determine whether or not the code is being compiled for use at design-time. The standard component library included with Elevate Web Builder tests for this symbol in many different places.

Defining Symbols
You can create a compiler define using the following syntax:

{$DEFINE <Symbol>}

Once a symbol has been defined, it will be effective for the remaining code in the current unit, including any units that are referenced after the symbol was defined. Defining a symbol that is already defined does nothing.

Warning Compiler defines are not nested. If a symbol is re-defined (it was already defined), and then un-defined, the result will be that the symbol will be undefined.

Un-Defining Symbols
You can remove a compiler define using the following syntax:

{$UNDEF <Symbol>}

Testing for Defined Symbols
To test whether a symbol has been defined, you can use the following syntax:

{$IFDEF <Symbol>}
// Include this code if the symbol is defined
[{$ELSE}]
// Include this code if the symbol is not defined (optional)
{$ENDIF}

To test whether a symbol has not been defined, you can use the following syntax:

{$IFNDEF <Symbol>}
// Include this code if the symbol is not defined
[{$ELSE}]
// Include this code if the symbol is defined (optional)
{$ENDIF}

An IFDEF or IFNDEF test must always be terminated with an ENDIF. The ELSE conditional branch is optional.

Example
The following is code from the standard component library that tests for the special DESIGN symbol to determine whether to use the WebDesign (IDE run-time) or the WebDOM (browser run-time) unit:

{$IFDEF DESIGN}
uses WebDesign, WebCore;
{$ELSE}
uses WebDOM, WebCore;
{$ENDIF}
Image