Directive #include Foundation

Inserts the contents of an Include file into a source code file

Syntax
#include "<IncludeFilename>"
Parameters
<IncludeFilename>
<IncludeFilename> designates the name of the file that the preprocessor should insert into the source code file. The file name must be enclosed in double quotes and can optionally contain a full or relative path and a file extension. If a relative path or no path is given, the preprocessor searches for the file in the following places, and in the following order:
In the current directory
In the directory of the file containing the #include directive
In the path specified by the compiler switch /I
In the path specified by the environment variable INCLUDE
The #include directive can also be present within an Include file. This provides the ability to nest Include files (to a limit of 25 levels), so that only a single#include directive is necessary in the source code.
Description

The #include directive causes the preprocessor to insert the contents of the indicated file into the source code file. Files that are inserted into the source code by the preprocessor are called Include files and should contain only Directives or REQUEST declarations. The contents of an Include file is inserted at the location of the #include directive. The default file extension for include files is ".CH". All Xbase++ Include files are located in the ..\INCLUDE directory.

#include directives are generally placed at the beginning of a source code file. Include files solve a fundamental problem with directives. Directives are scoped to the source file in which they are defined. This means that if the same directive is used in several source files, it must be defined in each file. The Include file provides a method to define directives in one file, and then just #include that file in each source file requiring one or more directives contained in that file. By their nature, Include files also promote better modularity, since maintenance of the various directives can be performed in one location.

The Include file "STD.CH" is automatically inserted into each PRG file by the preprocessor, without requiring a corresponding #include directive. The file "STD.CH" contains the directives for the translation of all Xbase++ commands. Instead of "STD.CH", another file can be used as the automatic Include file by using the /U compiler switch. The original "STD.CH" file should not be changed, though. If changes are desired, a copy of "STD.CH" should be made and that new copy should be incorporated using the /U compiler switch.

If an Include file contains executable program code, such as functions or procedures, that source code can't be viewed in the debugger.

Examples
#include usage sample
// In the example three Include files are inserted into the PRG file, 
// which contain various symbolic constants used in the source code. 

#include "Set.ch"              // Constants for the Set() function 
#include "Inkey.ch"            // Constants for Inkey() codes 
#include "SetCurs.ch"          // Constants for SetCursor() function 

PROCEDURE Main() 
   LOCAL cVar1 := Space(10) 
   LOCAL cVar2 := Space(20) 
   LOCAL cVar3 := Space(30) 
   LOCAL bBlock 
   // Setting code block for insert key 
   bBlock := SetKey(K_INS, {|| ChangeCursor()}) 

   CLS 
   @ 10, 10 SAY "Value1:" GET cVar1 
   @ 11, 10 SAY "Value2:" GET cVar2 
   @ 12, 10 SAY "Value3:" GET cVar3 
   READ 

   SetKey(K_INS, bBlock)       // Restoring old value 
RETURN 

PROCEDURE ChangeCursor() 
   Set(_SET_INSERT, .NOT. Set(_SET_INSERT)) 
   SetCursor(IIf(Set(_SET_INSERT), SC_SPECIAL1, SC_NORMAL)) 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.