The $include directive informs the compiler to include the contents of the filename into the source code as though the text in filename was typed directly into the source.
This is usually used for including files containing common global variable and constant declarations associated with particular function libraries (header files).
For example if the header file MYVARS.INC contains the following declarations:
myvars.inc:
var a:10;
var b:10;
const c="123";
This could be included in a global declaration_block at the top of the program:
$include "myvars.inc"
main
// these are decared in the header file..
a=1;
b=c;
endmain
Although the $include directive is most commonly used to include header files that declare global variable and constants there is no reason why the $include directive can;t be used anywhere in the code to include text from another file as though it had been typed directly into the source file.
For example in the following program
main
$include "stuff.txt"
endmain
The STUFF.TXT file can contain all the program statements for the application like this:
Stuff.txt
applog("This comes from the stuff.txt file");
applog("Hello again, world");
For header files the convention is to use the extension “.teh” (short for Telecom Engine Header), or if you prefer “.inc” or “.h” are other common extensions used.
An environment variable called INCDIR specifies a semi-colon delimited list of directories where the compile will search for include files (See TCL Compiler Reference).