$DEFINE Statement
Declares a symbol for use in a DataBasic program.
Syntax
$DEFINE symbol {value}
Syntax Elements
symbol An identifier to be used as a symbol.
value Any valid DataBasic expression.
Operation
$DEFINE can be used in two ways:
-
To define a symbol to be equivalent to a DataBasic expression. When you compile your program, a pre-processor replaces all occurrences of each symbol with the corresponding value.
When used in this way, $DEFINE is similar to the EQUATE statement, except that value extends to the end of the line.
-
To define a symbol for use with the $IFDEF and $IFNDEF statements to control conditional compilation. In this case, value can be omitted.
A symbol defined with $DEFINE can be undefined with the $UNDEFINE statement. It can then be defined again with $DEFINE. Note, however, the following restrictions:
-
Once set, the value of a defined symbol cannot be changed.
-
An undefined symbol cannot then be used as a variable.
Comments
Refer to the EQUATE statement for more information about defining a symbol to be equivalent to a DataBasic expression.
See Also
EQUATE statement, $IFDEF statement, $IFNDEF statement, $UNDEFINE statement.
Examples
$DEFINE PI 3.1416
Declares symbol PI to be equal to 3.1416.
$DEFINE PART.NO ITEM(3)
Equates PART.NO to array element number 3 of ITEM.
$DEFINE TODAY DATE() 'DJ'
Equates symbol TODAY to the current date, formatted as the Julian day (1-365 or 1-366 for a leap year).
$DEFINE DEBUG
Defines the symbol DEBUG. This can then be used with $IFDEF and $IFNDEF statements to include or exclude code from the compiled version.