Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-12

{$include %dateyear%}

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Il Grande Beppe

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'

Reply by email

James Richters
to Il Grande Beppe

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

Earlier message 19 lines
-----Original Message----- From: fpc-pascal On Behalf Of Il Grande Beppe via fpc-pascal Sent: Thursday, December 23, 2021 7:12 PM To: FPC-Pascal users discussions Cc: Il Grande Beppe 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'

Reply by email

Ched
to James Richters

Helolo James,

Thank you for your comment and proposal. As there is no type associated with non-string results, would it be better to say number instead of integer ? Or integer number ?

Season's greetings !

Cheers, Ched'

Le 24.12.2021 à 22:32, James Richters via fpc-pascal a écrit :

Show quoted text 75 lines
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 On Behalf Of Il Grande Beppe via fpc-pascal Sent: Thursday, December 23, 2021 7:12 PM To: FPC-Pascal users discussions Cc: Il Grande Beppe 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 - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

James Richters
to Ched

I see what you mean... I thought it was an Integer because If you do something like: Writeln({$I %DATEMONTH%}+'/'+{$I %DATEDAY%}+'/'+{$I %DATEYEAR%}); You get Error: Operator is not overloaded: "ShortInt" + "Char"

But that's not what it is.... it's just like typing in hard coded numbers after it's compiled.. because you can do things like Writeln('{$I %DATEMONTH%}'+'/');
And you wouldn't be able to do that with variables or any type... so it's really not any variable type, it's just numeric text being inserted.

I don't really know what to call it, but integer seems to indicate it has a type, so I agree it should be distinguished from any specific variable type.

James

Reply by email

Ched
to James Richters

Well, Writeln('{$I %DATEMONTH%}'+'/'); can be compiled, but the answer is... {$I %DATEMONTH%} .

I think that my level of english is by far too low to make the correct sentence.

Cheers, James, Raoul

Le 25.12.21 à 21:06, James Richters a écrit :

Show quoted text 12 lines
I see what you mean... I thought it was an Integer because If you do something like: Writeln({$I %DATEMONTH%}+'/'+{$I %DATEDAY%}+'/'+{$I %DATEYEAR%}); You get Error: Operator is not overloaded: "ShortInt" + "Char" But that's not what it is.... it's just like typing in hard coded numbers after it's compiled.. because you can do things like Writeln('{$I %DATEMONTH%}'+'/'); And you wouldn't be able to do that with variables or any type... so it's really not any variable type, it's just numeric text being inserted. I don't really know what to call it, but integer seems to indicate it has a type, so I agree it should be distinguished from any specific variable type. James

Reply by email