In this form:
{$INCLUDE %XXX%}
the {$INCLUDE} directive inserts a string constant in the source code.
Here XXX can be one of the following:
-
DATE
- Inserts the current date. It will be formatted as YYYY/MM/DD.
-
FPCTARGET
- Inserts the target CPU name. (deprecated, use FPCTARGETCPU)
-
FPCTARGETCPU
- Inserts the target CPU name.
-
FPCTARGETOS
- Inserts the target OS name.
-
FPCVERSION
- Current compiler version number.
-
FILE
- Filename in which the directive is found.
-
LINE
- Line number on which the directive is found.
-
LINENUM
- Line number on which the directive is found. In this case, the result is an
integer, not a string.
-
TIME
- Current time, formatted as HH:MM:SS
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).
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.