1.2.43 $I or $INCLUDE : Include compiler info

In this form:

{$INCLUDE %XXX%}

the {$INCLUDE} directive inserts a string constant in the source code.

Here XXX can be one of the following:

CURRENTROUTINE
Inserts the name of the current routine. Useful for debug logging.
DATE
Inserts the current date. It will be formatted as YYYY/MM/DD.
DATEYEAR
Inserts the year part of the current date.
DATEMONTH
Inserts the month part of the current date.
DATEDAY
Inserts the day part of the current date.
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.
TIMEHOUR
Hour part of the current time.
TIMEMINUTE
Minutes part of the current time.
TIMESECOND
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.