<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — read  statement hangs]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=852&amp;type=atom" />
	<updated>2022-04-15T12:12:56Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=852</id>
		<entry>
			<title type="html"><![CDATA[Re: read  statement hangs]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3908#p3908" />
			<content type="html"><![CDATA[<p>Imre,</p><p>I notice a couple things about your example.&nbsp; First, your format is looking for 80 single characters.&nbsp; When I use your format statement and enter text, I actually only get the first letter stored.&nbsp; You might instead want to use the more generic <em>&#039;(A)&#039;</em> text format for the read to make sure it reads all text up to the new line.</p><p>Regardless, I&#039;m not seeing a hang.&nbsp; My code:</p><div class="codebox"><pre><code>program cr
implicit none

    character(50)::line
    
    Print *, &quot;Enter some text:&quot;
    Read(*, &#039;(A)&#039;) line
    
    Print *, trim(line), len_trim(line)
    
end program cr</code></pre></div><p>seems to correctly register a string of zero length when I simply press <em>Enter</em>.&nbsp; Does the above work for you?</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2022-04-15T12:12:56Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3908#p3908</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: read  statement hangs]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3907#p3907" />
			<content type="html"><![CDATA[<p>Though it&#039;s probably overkill and superstition, I&#039;d assign something to Line first, even if it&#039;s just Line = &quot;&quot; or Line = &quot; &quot;,<br />then I&#039;d put a Write, just under the Read, to write out Line and test it with data content. Finally, just hit the enter key as before. I do understand that it hangs after the Read with just Enter, you may not get to the Write in that case.</p><p>I&#039;m suggesting those steps because it more clearly brackets the issue. And it would be interesting to see if hitting the space bar and Enter works too. I mean a &lt;space&gt; in this context is just as fine as a letter or other data.</p><p>Also, I&#039;m suspicious of that 80a1 format. Can you make it more generic - What does Read(*,&#039;(a)&#039;) line do in its place (with data and with just an enter? or try 1a1 and test with one character.</p><p>Are you using a Mac or PC Platform?</p><p>I would have tired some of my suggestions first, but I can&#039;t just copy the code you provided and run it here. It doesn&#039;t like the<br />Read(*,1) line<br />1 format(80a1)<br />construction. So I&#039;d need your I/O statement in there too - something so I can duplicate the same success/error result.</p>]]></content>
			<author>
				<name><![CDATA[designer]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3903</uri>
			</author>
			<updated>2022-04-14T18:04:05Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3907#p3907</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[read  statement hangs]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3906#p3906" />
			<content type="html"><![CDATA[<p>My code reads character input from the console, this works fine, but if you hit enter without entering any data the read hangs and the only way out is to do a cntrl-c. I have tried iostat=, err=, eor=, size= (with advance=&#039;mo&#039;) ... but I have not found a way to detect a carriage return.</p><p>&nbsp; &nbsp; &nbsp;read (*,1) line<br />1&nbsp; &nbsp;format (80a1)</p><br /><p>Thanks, Imre</p>]]></content>
			<author>
				<name><![CDATA[imre_varga]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3807</uri>
			</author>
			<updated>2022-04-14T16:11:28Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3906#p3906</id>
		</entry>
</feed>
