Include file (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Object Pascal Compiler Directives (List) Index




{$I filename} {$INCLUDE filename}




The $I parameter directive instructs the compiler to include the named file in the compilation. In effect, the file is inserted in the compiled text right after the {$I filename} directive.

The default extension for filename is .pas. A filename specified with no file extension always gets the .pas extension. If the filename does not specify a directory path, then, in addition to searching for the file in the same directory as the current module, Object Pascal searches in the directories specified in the Search path input box on the Object Pascal Compiler page of the Project > Options dialog box (or in the directories specified in a -I option on the dccil command line).

To specify a filename that includes a space, surround the file name with single quotation marks: {$I 'My file'}.

There is one restriction to the use of include files: an include file can't be specified in the middle of a statement part. In fact, all statements between the begin and end of a statement part must exist in the same source file.