In this form:
{$INCLUDE %XXX%}
the {$INCLUDE} directive inserts a string constant in the source code.
Here XXX can be one of the following:
Inserts the name of the current routine. Useful for debug logging.
Inserts the current date. It will be formatted as YYYY/MM/DD.
Inserts the year part of the current date.
Inserts the month part of the current date.
Inserts the day part of the current date.
Inserts the target CPU name. (deprecated, use FPCTARGETCPU)
Inserts the target CPU name.
Inserts the target OS name.
Current compiler version number.
Filename in which the directive is found.
Line number on which the directive is found.
Line number on which the directive is found. In this case, the result is an integer, not a string.
Current time, formatted as HH:MM:SS.
Hour part of the current time.
Minutes part of the current time.
Seconds part of the current time.
If XXX is none of the above, then it is assumed to be the name of an environment variable. Its value will be fetched from the environment, if it exists, otherwise an empty string is inserted. As a result, this will generate a macro with the value of the XXX specifier, as if it were a string (or, in the case of LINENUM, an integer).
Remark Note that the time arguments are the times when the directive is processed. Thus it is possible that different time stamps appear in the strings even if they are in the same unit but on different locations in the file.
For example, the following program
Program InfoDemo; Const User = {$I %USER%}; begin Write ('This program was compiled at ',{$I %TIME%}); Writeln (' on ',{$I %DATE%}); Writeln ('By ',User); Writeln ('Compiler version: ',{$I %FPCVERSION%}); Writeln ('Target CPU: ',{$I %FPCTARGET%}); end.
Creates the following output:
This program was compiled at 17:40:18 on 1998/09/09 By michael Compiler version: 0.99.7 Target CPU: i386
Remark Note that the inclusion of DATE and TIME will not cause the compiler to recompile the unit every time it is used: the date and time will be the date and time when the unit was last compiled.