[fpc-pascal] {$include %dateyear%}

James Richters james.richters at productionautomation.net
Fri Dec 24 23:32:19 CET 2021


I would agree that the documentation actually states quite clearly that they are ALL strings except %linenum% and the documentation should be improved to be accurate.

Perhaps 

{$INCLUDE %XXX%}
the {$INCLUDE} directive inserts a string or integer constant in the source code.
Here XXX can be one of the following:

CURRENTROUTINE
Inserts a string containing the name of the current routine. Useful for debug logging.
DATE
Inserts a string containing the current date. It will be formatted as YYYY/MM/DD.
DATEYEAR
Inserts an integer containing the year part of the current date.
DATEMONTH
Inserts an integer containing the month part of the current date.
DATEDAY
Inserts an integer containing the day part of the current date.
FPCTARGET
Inserts a string containing the target CPU name. (deprecated, use FPCTARGETCPU)
FPCTARGETCPU
Inserts a string containing the target CPU name.
FPCTARGETOS
Inserts a string containing the target OS name.
FPCVERSION
Inserts a string containing the current compiler version number.
FILE
Inserts a string containing the filename in which the directive is found.
LINE
Inserts a string containing the line number on which the directive is found.
LINENUM
Inserts an integer containing the line number on which the directive is found.
TIME
Inserts a string containing the current time, formatted as HH:MM:SS
TIMEHOUR
Inserts an integer containing the hour part of the current time.
TIMEMINUTE
Inserts an integer containing the minutes part of the current time.
TIMESECOND
Inserts an integer containing the 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 as a string from the environment when compiled, if it exists, otherwise an empty string is inserted.
(we don't need to mention the integer exceptions here  because we are only talking about environment variables now)

I didn't know these directives existed, so thanks for the Christmas present, these will be very useful!

James



-----Original Message-----
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Il Grande Beppe via fpc-pascal
Sent: Thursday, December 23, 2021 7:12 PM
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Cc: Il Grande Beppe <ilgrandebeppe at gmail.com>
Subject: [fpc-pascal] {$include %dateyear%}

Hello All,

I'm reading https://www.freepascal.org/docs-html/prog/progsu41.html

It seems to me that {$include %dateyear%} , {$include %datemonthr%}  and {$include %dateday%}  are treated as numbers in the source code, not a string as expected  from the description (only linenum is supposed to be a number).

I'm really happy with numbers, but I think that the description could be improved , isn't it ?

Best wishes and season's greetings to all Freepascalists.

Cheers, Ched'

_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list