<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Jumping out of Nested Do's the right way and request for cleverness]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=748&amp;type=atom" />
	<updated>2020-04-15T22:33:41Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=748</id>
		<entry>
			<title type="html"><![CDATA[Re: Jumping out of Nested Do's the right way and request for cleverness]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3469#p3469" />
			<content type="html"><![CDATA[<p>Found It!</p><p>I&#039;ve been reading a lot of .pdf files about Fortran 90 and see some of my confusion was old vs new syntax of Fortran 77 vs Fortran 90.</p><p>In the situation above, My IF statement was IF A .and. B and I&#039;m guessing wasn&#039;t happy because of &quot;IF A&quot; were it was expecting A to be logical type. So IF (A .and. B) fixed it.</p><p>I added back the .AND, instead of just &quot;and&quot; and put back the :: after the Integer type.<br />But the crux was to appropriately bracket the comparisons in the IF statement&nbsp; so it was IF (X .AND. Y) instead of IF X .AND. Y</p>]]></content>
			<author>
				<name><![CDATA[designer]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3903</uri>
			</author>
			<updated>2020-04-15T22:33:41Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3469#p3469</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Jumping out of Nested Do's the right way and request for cleverness]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3468#p3468" />
			<content type="html"><![CDATA[<p>An example of what I&#039;m asking about for a syntax reference is some books show variable declaration as</p><p>Integer :: MyVar</p><p>While others show just<br />Integer MyVar</p><p>Some references show the logical operators as OR AND and others show them as .OR. .AND.</p><p>I&#039;ve looked at the documentation on the SF support page but can&#039;t find what I&#039;m looking for in any of the content headings.</p><p>I&#039;ve googled Fortran References but haven&#039;t found one that explains why I&#039;m getting assigning to a named constant errors.</p><p>I started out with Fortran IV decades ago and have added that many years working with syntax for PL/1, COBAL, various BASIC compilers, Pascal, and a few others. So when getting back into it, there&#039;s a &quot;What does this compiler want it to look like&quot; level I need to know so the syntax becomes more &quot;muscle memory&quot; and I can focus on the algorithm itself.</p>]]></content>
			<author>
				<name><![CDATA[designer]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3903</uri>
			</author>
			<updated>2020-04-15T16:46:10Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3468#p3468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Jumping out of Nested Do's the right way and request for cleverness]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3467#p3467" />
			<content type="html"><![CDATA[<p>Here is the code I am playing with. I&#039;m thinking I&#039;ve been referencing some language definitions that might not match this compiler&#039;s syntax. In the example below, right after<br />IF (i/=o) AND (i/=g) AND (i/=w) AND (i/=y) AND (i/=a) AND (i/=h)&nbsp; &amp;<br />the error says I cannot assign a named constant (i) at 1</p><p>I get the same error with this statement<br />IF (Total1 == Liya) And (Total2 == Oyoo) Then</p><p>It&#039;s as if I defined my variables as integer constants instead of interger variables</p><p>Another error that popped up was a missing End Do, but That might be because of those other errors<br />If I comment out all the IF statements (and End IF) I compile without error.</p><p>What is a good source that defines the syntax for this compiler? For example, one book says I have to use .OR. .And. instead of just OR And. Or it says I have to use Integer :: myVar instead of just Integer myVar</p><br /><br /><p>Implicit None</p><p>! Define the loop variables that run 1 thu 9<br />! No leading character can be zero<br />Integer&nbsp; h, l, s, t</p><p>! Define the loop variables that run 0 thru 9<br />Integer&nbsp; i, o, g, w, y, a</p><p>! Define the variables that make up the equations<br />Integer&nbsp; Silo, High, Too, Low, So, Liya, Oyoo</p><p>! Define the equation totals<br />Integer&nbsp; Total1, Total2</p><p>Print *, &quot;Let the games begin&quot;<br />! Start the zero to nine loops<br /> ix: Do i = 0, 9<br />! Print the outer most loop to show we have a heart beat<br />Print *, &quot;i is &quot;, i<br />&nbsp; &nbsp; ox: Do o = 0,9<br />&nbsp; &nbsp; &nbsp; &nbsp; gx: Do g = 0,9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wx: Do w = 0,9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yx: Do y = 0,9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ax: Do a = 0,9<br /> ! Now the 1 to 9 loops<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hx: Do h = 1,9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lx: Do l = 1,9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sx: Do s = 1,9<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tx: Do t = 1,9<br /> ! Build the Variables<br /> ! Only when Indexes are unique<br /> IF (i/=o) AND (i/=g) AND (i/=w) AND (i/=y) AND (i/=a) AND (i/=h)&nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (i/=l) AND (i/=s) AND (i/=t)&nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (o/=g) AND (o/=w) AND (o/=y) AND (o/=a) AND (o/=h) AND (o/=l)&nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (o/=s) AND (o/=t)&nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (g/=w) AND (g/=y) AND (g/=a) AND (g/=h) AND (g/=l) AND (g/=s)&nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (g/=t) &amp;<br />&nbsp; &nbsp; AND&nbsp; (w/=y) AND (w/=a) AND (w/=h) AND (w/=l) AND (w/=s) AND (w/=t)&nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (y/=a) AND (y/=h) AND (y/=l) AND (y/=s) AND (y/=t)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;<br />&nbsp; &nbsp; AND&nbsp; (a/=h) AND (a/=l) AND (a/=s) AND (a/=t)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;<br />&nbsp; &nbsp; AND&nbsp; (l/=s) AND (l/=t) AND (s/=t) THEN</p><p> Silo = o + 10*l + 100*i + 1000*s<br /> High = h + 10*g + 100*i + 1000*h<br /> Too = o + 10*o + 100*t</p><p> Low = w + 10*o + 100*l<br /> So = o + 10*s</p><p> Liya = a + 10*y + 100*i + 1000*l<br /> Oyoo = o + 10*o + 100*y + 1000*o</p><p> ! Test the equations</p><p> Total1 = Silo + High + Too<br /> Total2 = Silo + Low + So</p><p>&nbsp; &nbsp; &nbsp; &nbsp;IF (Total1 == Liya) And (Total2 == Oyoo) Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Silo is &quot;, Silo<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;High is &quot;, High<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Too is &quot;, Too<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Total is &quot;, Total1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Liya is &quot;, Liya<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Silo is &quot;, Silo<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Low is &quot;, Low<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;So is &quot;, So<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;____________________&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Total is &quot;, Total2<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Oyoo is &quot;, Oyoo<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;i is &quot;, i, &quot;o is &quot;, o, &quot;g is &quot;, g, &quot;w is &quot;, w, &quot;y is &quot;, y<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;a is &quot;, a, &quot;h is &quot;, h, &quot;l is &quot;, l, &quot;s is &quot;, s, &quot;t is &quot;, t<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print *, &quot;Finished&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Stop<br />&nbsp; &nbsp; &nbsp; &nbsp; End IF<br />&nbsp; &nbsp; End IF</p><p> End Do tx<br /> End Do sx<br /> End Do lx<br /> End Do hx<br /> End Do ax<br /> End Do yx<br /> End Do wx<br /> End Do gx<br /> End Do ox<br /> End Do ix<br />Print *, &quot;Finished&quot;<br />Stop<br />End Program</p>]]></content>
			<author>
				<name><![CDATA[designer]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3903</uri>
			</author>
			<updated>2020-04-15T06:36:48Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3467#p3467</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Jumping out of Nested Do's the right way and request for cleverness]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3466#p3466" />
			<content type="html"><![CDATA[<p>As a test/gettoknowya exercise I&#039;m playing with nested Do loops. My project is 10 deep but for simplicity I&#039;ll ask about a 3 deep situation.</p><p>I&#039;ve seen commands &quot;Cycle&quot; and &quot;Exit&quot; and I know what they do within one loop. If I am nested in<br />A<br />&nbsp; B<br />&nbsp; &nbsp; C<br />And I Cycle in C, I know it skips an iteration for C. It seems if I am in B and Cycle out, I skip the iteration for B and ALL of C. Same with A, If I cycle out of A, All of B and C are skipped for that Cycle - Correct?</p><p>Now for an Exit, If I Exit in the middle of the increment range of C, I&#039;m still in the loop of B so will come back into C on the next iteration of B - Correct?</p><p>So - If I&#039;m in the loop of C and my criteria is meet so I don&#039;t need any more looping, what is the best way to exit from the &quot;center&quot; of the three nested Do Loops?</p><p>I have read and searched, but most examples deal with simple, 1 tier, cases.</p><p>In this exercise, I need to run A, B, and C though numbers 0 thru 9, So I have them nested in Do&#039;s, each going from 0 to 9 and a Brute Force visit of possibilities. BUT I ONLY NEED to test a condition with all three indexes are unique.</p><p>At this point I have a huge IF statement that check that index A isn&#039;t equal to B or C AND B isn&#039;t equal to A or C AND C isn&#039;t equal to A or B. Is there a more elegant way to run A, B, and C thorough all numbers 0 to 9 but have a cleaner way of testing my condition only when each has a unique value?</p><p>In the real situation, I have 10 Do loop indexes and only need to test when all 10 have unique values.<br />In brute force, it seems like 10 to the power of 10 iterations. It would be nice if I could cut that down by only allowing all ten to take on every value from 0 to 10 but only generate values that are always unique with respect to one another.</p><p>Thank you.</p>]]></content>
			<author>
				<name><![CDATA[designer]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3903</uri>
			</author>
			<updated>2020-04-15T01:47:29Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3466#p3466</id>
		</entry>
</feed>
