INCLUDE Preprocessor Directive Example
In the following example, two files are used: Const.h, a header file, and Myprog.prg, a program file. The header file contains several #DEFINE directives that create compile-time constants. The program file uses #INCLUDE to merge the Const.h header file at compilation, making the compile-time constants in the header file available to the program.
*** Header file CONST.H ***
#DEFINE ERROR_NODISK 1
#DEFINE ERROR_DISKFULL 2
#DEFINE ERROR_UNKNOWN 3
*** Program file MYPROG.PRG ***
#INCLUDE CONST.H
FUNCTION chkerror
PARAMETER errcode
DO CASE
CASE errcode = ERROR_NODISK
?"Error - No Disk"
CASE errcode = ERROR_DISKFULL
?"Error - Disk Full"
CASE errcode = ERROR_UNKNOWN
?"Unknown Error"
ENDCASE
RETURN