<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Option to recognise a date string in source code , and auto-update it]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=90&amp;type=atom" />
	<updated>2013-02-17T23:03:22Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=90</id>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=565#p565" />
			<content type="html"><![CDATA[<p>This works perfectly.&nbsp; It is a great way to generate a date string which can be used to display in program output, next to teh program version number, the build date.&nbsp; many thanks, Jeff.<br />--- <br />John</p>]]></content>
			<author>
				<name><![CDATA[JohnWasilewski]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=102</uri>
			</author>
			<updated>2013-02-17T23:03:22Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=565#p565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=562#p562" />
			<content type="html"><![CDATA[<p>To all:</p><p>Jeff has point out to me, </p><p><em>It appears that &quot;Always Regenerate Makefile&quot; is still disabled in your<br />project.&nbsp; It should work if you re-enable it from the Project Options<br />dialog.&nbsp; Alternatively, you can select &quot;Generate Makefile&quot; from the<br />Build menu directly.</em></p><p>Thanks Jeff.&nbsp; I really must check everything more carefully!<br />--- <br />John</p>]]></content>
			<author>
				<name><![CDATA[JohnWasilewski]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=102</uri>
			</author>
			<updated>2013-02-16T14:22:49Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=562#p562</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=561#p561" />
			<content type="html"><![CDATA[<p>I&#039;ve just tried again to compile.<br />I list at the end the options I had selected, which were already in the project file as saved.</p><p>Here, first, is the compilation output:</p><p>==============================================================================<br />Open Watcom Make Version 1.9 (Built on Feb&nbsp; 4 2013)<br />Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.<br />Source code is available under the Sybase Open Watcom Public License.<br />See <a href="http://www.openwatcom.org/">http://www.openwatcom.org/</a> for details.<br />&nbsp; &nbsp; &quot;C:\Program Files (x86)\FORTRAN\SF\mingw-w64\bin\gfortran.exe&quot; -c -o &quot;build\INSTRUCT.o&quot; -g -IG:/InStruct120/../MODULES -IG:/InStruct120/../INCLUDE -fdollar-ok -Jmodules &quot;.\Source\INSTRUCT.for&quot;<br />.\Source\INSTRUCT.for:230.22:</p><p>&nbsp; &nbsp; &nbsp; DateCompiled = __DATE__&nbsp; ! Invokes a macro in the C language&nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br />Error: Invalid character in name at (1)<br />Error(E42): Last command making (build\INSTRUCT.o) returned a bad status<br />Error(E02): Make execution terminated</p><p>* Complete *</p><br /><p>Relevant options set are (I am copying and pasting here:</p><p>COMPILER<br />Fortran compiler flags: -cpp<br />C compiler flags: -cpp</p><p>PROJECT<br />Project flags<br />Fortran compiler: -fdollar-ok -cpp<br />C compiler: -cpp<br />Linker: -luser32 -lgdi32 -lopengl32 </p><p>I have tried many combinations of where to put&nbsp; &#039;-cpp&#039;, as a compiler flag, a project flag, in Fortran, then C, then Fortran and C.&nbsp; </p><p>I can see that &#039;-cpp&#039; isn&#039;t in the gfortran compiler line output report, but it IS in the options I selected.<br />I can&#039;t offer any explanation for this.<br />---- <br />John</p>]]></content>
			<author>
				<name><![CDATA[JohnWasilewski]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=102</uri>
			</author>
			<updated>2013-02-15T23:01:38Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=561#p561</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=560#p560" />
			<content type="html"><![CDATA[<p>John,</p><p>Just glancing at your compiler output, I can see that the <em>-cpp</em> option isn&#039;t in your compiler line.&nbsp; Which options did you add it to?&nbsp; I added it to &quot;Compiler Flags&quot; under &quot;Fortran&quot; in the Compiler Options window.&nbsp; Alternatively, it should work if you add it to the Fortran Compiler flags in Project Options.&nbsp; Also make sure your Makefile is set to be regenerated.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2013-02-15T19:28:29Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=560#p560</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=559#p559" />
			<content type="html"><![CDATA[<p>Sounds a really neat trick Jeff but I don&#039;t know enough about C to make it work.</p><p>eg I put the -cpp flag in the compilet options and then tried this:</p><br /><br /><p>&nbsp; &nbsp; &nbsp; CHARACTER DateToday*9, DateCompiled*11<br />&nbsp; &nbsp; &nbsp; EXTERNAL DisplayBanner, Read_Eng</p><p>&nbsp; &nbsp; &nbsp; DateCompiled = __DATE__&nbsp; ! Invokes a macro in the C language<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;! as long as compiler flag -cpp is set.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;! Date will be in the form, &quot;Feb 15 2013&quot;.<br />&nbsp; &nbsp; &nbsp; PROG8&nbsp; = &#039;INSTRUCT&#039;<br />&nbsp; &nbsp; &nbsp; VERS4&nbsp; &nbsp;= &#039;1.20&#039;<br />C&nbsp; &nbsp; &nbsp;PDAT8&nbsp; = &#039;21.02.13&#039;<br />&nbsp; &nbsp; &nbsp; PDAT8&nbsp; &nbsp;= DateCompiled(5:6)//&#039; &#039;//<br />&nbsp; &nbsp; &nbsp;+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateCompiled(1:2)//&#039; &#039;//<br />&nbsp; &nbsp; &nbsp;+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateCompiled(10:11)</p><p>&nbsp; &nbsp; &nbsp; DESC24 = &#039;Plane frame analysis&#039;<br />&nbsp; &nbsp; &nbsp; AUTH16 = &#039;John Wasilewski&#039;<br />&nbsp; &nbsp; &nbsp; CPRT17&nbsp; = &#039;(c) 2004-2013 Jmw&#039;</p><br /><br /><br /><br /><p>It fails to compile because Fortran doesn&#039;t recognise <br />The compilation error is this:</p><p>&quot;C:\Program Files (x86)\FORTRAN\SF\mingw-w64\bin\gfortran.exe&quot; -c -o &quot;build\INSTRUCT.o&quot; -g -IG:/InStruct120/../MODULES -IG:/InStruct120/../INCLUDE -fdollar-ok -Jmodules &quot;.\Source\INSTRUCT.for&quot;<br />.\Source\INSTRUCT.for:229.22:</p><p>&nbsp; &nbsp; &nbsp; DateCompiled = __DATE__&nbsp; ! Invokes a macro in the C language&nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br />Error: Invalid character in name at (1)<br />Error(E42): Last command making (build\I.NSTRUCT.o) returned a bad status<br />Error(E02): Make execution terminated</p><p>Further guidance would be a great help.</p><p>--- <br />John</p>]]></content>
			<author>
				<name><![CDATA[JohnWasilewski]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=102</uri>
			</author>
			<updated>2013-02-15T19:21:28Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=559#p559</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=558#p558" />
			<content type="html"><![CDATA[<p>John,</p><p>I started looking into this a bit, but I think there is a simpler situation.&nbsp; One thing you can do is add the &quot;-cpp&quot; flag to the Fortran compiler flags, which will cause the Fortran source code to be passed through the C preprocessor.&nbsp; The C preprocessor has a predefined macro <em>__DATE__</em>.&nbsp; This macro will be converted to the date at compilation time in the form &quot;Feb 15 2013&quot; when encountered.&nbsp; A sample bit of code appears below:</p><div class="codebox"><pre><code>program helloworld
implicit none

    Print *, __DATE__
    
end program helloworld</code></pre></div><p>The program will simply output the date as long as &quot;-cpp&quot; is added to the Fortran compiler flags.</p><p>Alternatively, if the file has a uppercase extension, like <em>.F</em> or <em>.F03</em>, the compiler flag isn&#039;t necessary; these files will always be passed through the C preprocessor.</p><p>Some other useful macros can be found at:</p><p><a href="http://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html#Predefined-Macros">http://gcc.gnu.org/onlinedocs/cpp/Prede … ned-Macros</a></p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2013-02-15T17:51:21Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=558#p558</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=474#p474" />
			<content type="html"><![CDATA[<p>Jeff, you don&#039;t seem ever to have commented on this request.<br />I can see that it would be a bit unusual.&nbsp; <br />Is it not something you think worth exploring?<br />---<br />John</p>]]></content>
			<author>
				<name><![CDATA[JohnWasilewski]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=102</uri>
			</author>
			<updated>2013-01-15T18:44:53Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=474#p474</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Option to recognise a date string in source code , and auto-update it]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=288#p288" />
			<content type="html"><![CDATA[<p>Jeff,</p><p>My projects generally <br />(i) show the program version numbers in the code and <br />(ii) contain code to display program version no. and version date in the&nbsp; program output.<br />To achieve this, I have to enter the date I wish the program to display, as a text string, in the source code.</p><p>EXAMPLE</p><p>Code fragment<br />&nbsp; &nbsp; &nbsp; PROGRAM INSTRUCT<br />C&nbsp; &nbsp; ---------------------<br />C&nbsp; &nbsp; Last amended 27.04.12<br />&nbsp; &nbsp; &nbsp; :<br />&nbsp; &nbsp; &nbsp; USE DISLIN<br />&nbsp; &nbsp; &nbsp; :<br />&nbsp; &nbsp; &nbsp; :<br />&nbsp; &nbsp; &nbsp; PARAMETER (PROG8&nbsp; = &#039;INSTRUCT&#039;)<br />&nbsp; &nbsp; &nbsp; PARAMETER (VERS4&nbsp; = &#039;1.20&#039;)<br />&nbsp; &nbsp; &nbsp; PARAMETER (PDAT8&nbsp; = &#039;27.04.12&#039;)<br />&nbsp; &nbsp; &nbsp; PARAMETER (DESC24 = &#039;Plane frame analysis&#039;)<br />&nbsp; &nbsp; &nbsp; PARAMETER (AUTH16 = &#039;John Wasilewski&#039;)<br />&nbsp; &nbsp; &nbsp; PARAMETER (CPRT16 = &#039;(c) JW 2004-2012&#039;)<br />&nbsp; &nbsp; &nbsp; :<br />&nbsp; &nbsp; &nbsp; :<br />&nbsp; &nbsp; &nbsp; CALL SWGTXT(idSCR,&#039;vers. &#039;&nbsp; //VERS4//&#039; :&nbsp; &nbsp;&#039;//PDAT8)<br />&nbsp; &nbsp; &nbsp; CALL SWGTXT(idSCR,&#039;vers. &#039;&nbsp; //VERS4//&#039; :&nbsp; &nbsp;&#039;//PDAT8)</p><p>C&nbsp; &nbsp; (note: SWGTXT is a DISLIN routine to display a text string)</p><p>This produces program output thus:</p><p>Program INSTRUCT<br />vers. 1.20 :&nbsp; </p><br /><p>Can you find a way of having the editor generate and the current date WITHIN THE source code?<br />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.</p><p>Important: the date field would need to auto-update only in certain precise circumstances, namely,<br />(1) whenever any source file in the project is amended and saved.<br />(2) whenever the project structure is re-saved.<br />(3) whenever the project is re-built.</p><p>BUT not merely<br />(4) because another day has passed and the date has changed<br />(5) when printing.</p><p>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 &quot;27.04.12&quot; 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.&nbsp; They would of course need to be visually identifiable to someone reading the code, as fields not source code text.&nbsp; This could be done by either a text colour or, perhaps, a background colour.&nbsp; Another idea would be by having the text appear in italics.&nbsp; </p><p>Another idea would be just to provide a Simply Fortran option that recognises a date string in a certain format as an updating field.&nbsp; I like this idea the most because the source code really would then just be a text file, making it portable to other compilers.<br />--- <br />John</p>]]></content>
			<author>
				<name><![CDATA[JohnWasilewski]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=102</uri>
			</author>
			<updated>2012-04-28T00:40:31Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=288#p288</id>
		</entry>
</feed>
