<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Coding assistance]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=717&amp;type=atom" />
	<updated>2019-08-03T18:34:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=717</id>
		<entry>
			<title type="html"><![CDATA[Re: Coding assistance]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3319#p3319" />
			<content type="html"><![CDATA[<p>Hi all!</p><p>I received assistance from Dr Walt Brainerd of the Fortran Company.</p><p>See Fortran code for this request:</p><p>program Gary</p><p>&nbsp; &nbsp;implicit none<br />&nbsp; &nbsp;character(len=*), parameter :: text = &quot;Gary&quot;<br />&nbsp; &nbsp;character(len=100) :: line<br />&nbsp; &nbsp;integer :: gary_unit, ios<br />&nbsp; &nbsp;logical :: found_it</p><p>&nbsp; &nbsp;open (newunit=gary_unit, file=&quot;gary_file&quot;, &amp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;status=&quot;old&quot;, action=&quot;read&quot;, position=&quot;rewind&quot;)<br />&nbsp; &nbsp;found_it = .false.<br />&nbsp; &nbsp;do<br />&nbsp; &nbsp; &nbsp; read(unit=gary_unit, fmt=&quot;(a)&quot;, iostat=ios) line<br />&nbsp; &nbsp; &nbsp; if (is_iostat_end(ios)) exit<br />&nbsp; &nbsp; &nbsp; if (index(line, text) &gt; 0) then<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;! Uncomment this &quot;if&quot; test to insert the line just once<br />!&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (.not. found_it) &amp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write(unit=*, fmt=&quot;(a)&quot;) &quot;Line to be inserted&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;found_it = .true.<br />&nbsp; &nbsp; &nbsp; end if<br />&nbsp; &nbsp; &nbsp; write(unit=*, fmt=&quot;(a)&quot;) trim(line)<br />&nbsp; &nbsp;end do</p><p>end program Gary</p><p>Here is the input file &quot;gary_file&quot;. Create it with this name, no file extension.</p><p>line 1 aaaaaaaaa<br />line 2 bbbGarybbbb<br />line 3 ccccccc<br />line 4 Gary ddddd<br />line 5 eeee</p><p>Here is the output:</p><p>line 1 aaaaaaaaa<br />Line to be inserted<br />line 2 bbbGarybbbb<br />line 3 ccccccc<br />Line to be inserted<br />line 4 Gary ddddd<br />line 5 eeee</p>]]></content>
			<author>
				<name><![CDATA[GS76]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3865</uri>
			</author>
			<updated>2019-08-03T18:34:11Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3319#p3319</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Coding assistance]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3318#p3318" />
			<content type="html"><![CDATA[<p>Sounds like a typical programming course lab assignment.</p><p>There are many ways to do this task.&nbsp; You can&#039;t really &quot;insert&quot; lines into a text file, but you can copy the lines above the insert to a scratch file, write out the &quot;insert lines&quot;, and then copy the rest of the existing lines into the scratch file.&nbsp; Once that is done, you could delete the original file and rename the scratch file and you are done.</p><p>However, none of this will make any sense until you learn some basic Fortran.&nbsp; If you google Fortran tutorial you will find many online resources to get you started.</p>]]></content>
			<author>
				<name><![CDATA[baf1]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3660</uri>
			</author>
			<updated>2019-07-30T21:14:42Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3318#p3318</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Coding assistance]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3317#p3317" />
			<content type="html"><![CDATA[<p>Hi all,</p><p>Any assistance with regards my request.</p><p>I am new to programming and Fortran.</p><p>I wanted to know how to do the following:</p><p>1. Open a text file.<br />2. Insert &quot;text&quot; at a particular line number in the text file and/or before certain text in the file.<br />3. Save the file.<br />4. Close the file.</p><p>I would even pay for someone to assist me with this as it is a rush!</p><p>Where can I learn Fortran and/or do online training courses etc.</p><p>Thank you in advance.</p>]]></content>
			<author>
				<name><![CDATA[GS76]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3865</uri>
			</author>
			<updated>2019-07-30T13:39:07Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3317#p3317</id>
		</entry>
</feed>
