0

David H asked the following question: How can I automate getting the date of build into a constant visible to my code?

I was wondering if it is possible to get the modified date of a .pas file (unit) in the project and make it available to your code through a function or constant.

Community
  • 1
  • 1
Blurry Sterk
  • 1,595
  • 2
  • 9
  • 18
  • 2
    Pre-build action to create a .rc script which you then compile into a .res file which is linked to your unit. – David Heffernan Feb 15 '17 at 11:30
  • Why make it an rc file? You could also generate unit source code or an include file that is included into a unit (so the unit doesn't need to be changed). – dummzeuch Feb 15 '17 at 16:18
  • in this case, the OP is asking for a per-unit timestamp, so creating a `.rc`/`.res` file would not be appropriate. I would suggest writing a pre-build script that reads the `.pas` file's timestamp and stores it in an `.inc` file that can then be included where needed. – Remy Lebeau Feb 15 '17 at 17:03
  • @remy Why would per unit mean that you couldnt use a resource. An include file would of course also work. And may very well be more convenient. But a resource is no more difficult. One nice advantage is that you could create a single resource script with all the information for all included units and have it read by the program itself, or by external tools. – David Heffernan Feb 15 '17 at 20:20

0 Answers0