Topic: Option to recognise a date string in source code , and auto-update it
Jeff,
My projects generally
(i) show the program version numbers in the code and
(ii) contain code to display program version no. and version date in the program output.
To achieve this, I have to enter the date I wish the program to display, as a text string, in the source code.
EXAMPLE
Code fragment
PROGRAM INSTRUCT
C ---------------------
C Last amended 27.04.12
:
USE DISLIN
:
:
PARAMETER (PROG8 = 'INSTRUCT')
PARAMETER (VERS4 = '1.20')
PARAMETER (PDAT8 = '27.04.12')
PARAMETER (DESC24 = 'Plane frame analysis')
PARAMETER (AUTH16 = 'John Wasilewski')
PARAMETER (CPRT16 = '(c) JW 2004-2012')
:
:
CALL SWGTXT(idSCR,'vers. ' //VERS4//' : '//PDAT8)
CALL SWGTXT(idSCR,'vers. ' //VERS4//' : '//PDAT8)
C (note: SWGTXT is a DISLIN routine to display a text string)
This produces program output thus:
Program INSTRUCT
vers. 1.20 :
Can you find a way of having the editor generate and the current date WITHIN THE source code?
It would need to display the date as a text string within the source code line, exactly as if typed in, but with the date string actually being a date-text field, not a simple text string.
Important: the date field would need to auto-update only in certain precise circumstances, namely,
(1) whenever any source file in the project is amended and saved.
(2) whenever the project structure is re-saved.
(3) whenever the project is re-built.
BUT not merely
(4) because another day has passed and the date has changed
(5) when printing.
What I was thinking of would cause the above example to look exactly the same as above, but the two locations in the code where the date "27.04.12" appears, would actually have been entered in the source code as date-string field, not typed in, and would automatically update according to the above rules. They would of course need to be visually identifiable to someone reading the code, as fields not source code text. This could be done by either a text colour or, perhaps, a background colour. Another idea would be by having the text appear in italics.
Another idea would be just to provide a Simply Fortran option that recognises a date string in a certain format as an updating field. I like this idea the most because the source code really would then just be a text file, making it portable to other compilers.
---
John