<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — String Index function]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=734&amp;type=atom" />
	<updated>2020-02-20T16:54:10Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=734</id>
		<entry>
			<title type="html"><![CDATA[Re: String Index function]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3413#p3413" />
			<content type="html"><![CDATA[<p>The statement</p><p>testString=TRIM(testString)</p><p>essentially does nothing.&nbsp; The RHS expression does produce a character string without the trailing blanks, but<br />then that string is assigned back to testString, which has a length greater than the trimmed string, so it gets blank filled on the right (i.e., back exactly like it was before this statement was executed).</p>]]></content>
			<author>
				<name><![CDATA[baf1]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3660</uri>
			</author>
			<updated>2020-02-20T16:54:10Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3413#p3413</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String Index function]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3412#p3412" />
			<content type="html"><![CDATA[<p>Thanks for the quick response to get me functional!!!! I had tried </p><p>&nbsp; testString=TRIM(testString)<br />&nbsp; &nbsp;if(index(myString, testString) == 0) then</p><p>but that did/does not work.<br />It appears that the trim must be inside the index call</p>]]></content>
			<author>
				<name><![CDATA[bobrrm]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3898</uri>
			</author>
			<updated>2020-02-20T14:58:38Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3412#p3412</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String Index function]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3411#p3411" />
			<content type="html"><![CDATA[<p>The issue is that the index function is not searching simply for &quot;test.&quot;&nbsp; It is actually searching for the following in quotes:</p><div class="codebox"><pre><code>&quot;test                 &quot;</code></pre></div><p>In the first case, the index function is looking for the word &quot;test&quot; followed by 16 spaces, which does occur in your string <em>myString</em>, but in the second case, looking for &quot;test&quot; followed by 17 spaces fails.</p><p>What you actually want to find is just the word &quot;test.&quot;&nbsp; You can use the <em>trim()</em> intrinsic in your call to the <em>index()</em> function to make sure it works properly:</p><div class="codebox"><pre><code>index(myString, trim(test))</code></pre></div><p>which will work as you&#039;d expect.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2020-02-20T12:17:50Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3411#p3411</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[String Index function]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3410#p3410" />
			<content type="html"><![CDATA[<p>Was having difficulty with writting a program dealing with lots of character string manipulation.&nbsp; After digging around I narrowed it down to the following behavior.&nbsp; Perhaps I am missing something but the following seems to indicate a problem in the index function. Can someone please assist? running Build 3177</p><p>program testindex<br />implicit none</p><p>&nbsp; &nbsp;character(len=30) :: myString<br />&nbsp; &nbsp;character(len=20) :: testString<br />&nbsp; &nbsp;myString = &#039;This is a test&#039;<br />&nbsp; &nbsp;testString = &#039;test&#039;<br />&nbsp; &nbsp;testString=adjustL(testString)<br />&nbsp; &nbsp;if(index(myString, testString) == 0)then<br />&nbsp; &nbsp; &nbsp; print *, &#039;test is not found&#039;<br />&nbsp; &nbsp;else<br />&nbsp; &nbsp; &nbsp; print *, &#039;test is found at index: &#039;, index(myString, testString)<br />&nbsp; &nbsp;end if<br />end program testindex</p><p>output is:<br /> test is found at index:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;11</p><p>Result as expected however if you recompile but change len=20 to len =21 for teststring<br />i.e.<br />program testindex<br />implicit none</p><p>&nbsp; &nbsp;character(len=30) :: myString<br />&nbsp; &nbsp;character(len=21) :: testString<br />&nbsp; &nbsp;myString = &#039;This is a test&#039;<br />&nbsp; &nbsp;testString = &#039;test&#039;<br />&nbsp; &nbsp;testString=adjustL(testString)<br />&nbsp; &nbsp;if(index(myString, testString) == 0)then<br />&nbsp; &nbsp; &nbsp; print *, &#039;test is not found&#039;<br />&nbsp; &nbsp;else<br />&nbsp; &nbsp; &nbsp; print *, &#039;test is found at index: &#039;, index(myString, testString)<br />&nbsp; &nbsp;end if<br />end program testindex</p><p>output is:<br />test is not found</p>]]></content>
			<author>
				<name><![CDATA[bobrrm]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3898</uri>
			</author>
			<updated>2020-02-19T23:45:27Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3410#p3410</id>
		</entry>
</feed>
