#define

Define a constant name and value.

#define  Constant { = } Expression

Parameters

  • Constant—name of the constant

  • Expression—expression that evaluates to a constant value

Description

The #define directive defines a constant name and value during compilation for the current scope. For example, a constant declared within a scope block (initiated by a #startdefine directive) will be defined for the rest of the block until the corresponding #enddefine statement.

You can use constants as operands in expressions in ProcScript by placing the name of the constant between angle brackets (<>). When a component is compiled, the compiler replaces each reference to a constant by the expression that has been defined for that constant.

To define global constants, define them in a DEFPARAM IncludeScript. If they are defined in the IncludeScript library called SYSTEM_LIBRARY, they are available to all your Uniface applications.

Defining a Constant

The following example defines a constant MYCONSTANT with the text I'm defined. If the constant exists, the compiler generates a warning with the text of MYCONSTANT:

#define MYCONSTANT = I'm defined
#ifdefined MYCONSTANT
   #warning <MYCONSTANT>
#endif

This results, after compilation, in the following message in the message frame:

warning: 1000 - I'm defined

Related Topics