$INCLUDE compiler directive

$INCLUDE Compiler Directive

Top  Previous  Next


The $INCLUDE directive is used to direct the compiler to include text from another record. Include records may be in either directory or hashed files.




$INCLUDE { filename } record.id


For compatibility with some other systems, $INSERT may be used as a synonym for $INCLUDE.








The first example includes record ERR.H from the SYSCOM file. The second example, which has no file name specified, includes MYKEYS.H from the same file as the source program.


Use of a .H suffix is recommended on include records as these will be skipped automatically by the compiler when using a select list.


The file name in the first $INCLUDE in this example is not strictly necessary as the default behaviour of the compiler is always to look in SYSCOM if no file name is given and the include record is not found in the same file as the source program. The sequence of locations searched for the include record when no filename is specified can be modified by use of the SEARCH directive in the $BASIC.OPTIONS record.


Because directory files on non-Windows platforms have case sensitive record names, the compiler will look for the record name as entered and then, if it has not been found, in uppercase. Thus programs may be written in either upper or lowercase if the records are always stored with uppercase name. The standard include records in the SYSCOM file follow this rule.


Include files may be nested (one included from within another) though this can lead to difficulties when maintaining complex programs and is discouraged.


For compatibility with other multivalue databases, the $INCLUDE directive can also be written without the $ prefix. Used in this way, it must be the only statement on the source line and the filename and record.id must not correspond to tokens that have been defined using $DEFINE or EQUATE.