$I or $INCLUDE : Include file

The {$I filename} or {$INCLUDE filename} directive tells the compiler to read further statements from the file filename. The statements read there will be inserted as if they occurred in the current file.

The compiler will append the .pp extension to the file if no extension is given. Do not put the filename between quotes, as they will be regarded as part of the file’s name.

Include files can be nested, but not infinitely deep. The number of files is restricted to the number of file descriptors available to the Free Pascal compiler.

Contrary to Turbo Pascal, include files can cross blocks. I.e. a block can start in one file (with a Begin keyword) and can end in another (with a End keyword). The smallest entity in an include file must be a token, i.e. an identifier, keyword or operator.

The compiler will look for the file to include in the following places:

  1. It will look in the path specified in the include file name.
  2. It will look in the directory where the current source file is.
  3. it will look in all directories specified in the include file search path.

Directories can be added to the include file search path with the -I command-line option.