<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: While loop won't end in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745935#M24477</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Casting numtins to an int made it work.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 May 2010 18:51:21 GMT</pubDate>
    <dc:creator>KyleGallagher</dc:creator>
    <dc:date>2010-05-13T18:51:21Z</dc:date>
    <item>
      <title>While loop won't end</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745933#M24475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can't get my while loop to terminate even though I'm using a counter variable.&amp;nbsp; I've included th relevant code and bolded the area of interest below.&amp;nbsp; I'm thinking it has to do with the numtins parameter.&amp;nbsp; The parameter is setup as an "Any Value" type, and I'm not sure if the code is reading it as a number or not.&amp;nbsp; For example, if I input the number 3 as the value of the numtins parameter, I would expect my output to be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;.....but instead, it is an infinite.&amp;nbsp; What am i missing here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys, string, os, arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Create the Geoprocessor object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Check out any necessary licenses&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CheckOutExtension("spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CheckOutExtension("3D")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Read Parameters...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dem_ft = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outfolder = sys.argv[2]&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;numtins = sys.argv[3]&lt;BR /&gt;&lt;BR /&gt;counter = 1&lt;BR /&gt;&lt;BR /&gt;while counter &amp;lt;= numtins:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print counter&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE:&amp;nbsp; THE TWO LINES IN THE WHILE LOOP ARE INDENTED, I CAN'T GET THEM TO SHOW UP THAT WAY IN THE THREAD.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 May 2010 17:50:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745933#M24475</guid>
      <dc:creator>KyleGallagher</dc:creator>
      <dc:date>2010-05-13T17:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: While loop won't end</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745934#M24476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure if you're running this as a script tool or through an IDE.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty sure its getting confused with your numtins, it doesnt know that its an integer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following works for me (casting the input to an INT and passing in a value of say 5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import sys, os

numtins = int(sys.argv[1])

counter = 1

print numtins
os.system("pause")

while counter &amp;lt;= numtins:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print counter
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise just add in the pause statment and print out numtins (just to be sure what you're comparing)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:43:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745934#M24476</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2021-12-12T07:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: While loop won't end</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745935#M24477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Casting numtins to an int made it work.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 May 2010 18:51:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/while-loop-won-t-end/m-p/745935#M24477</guid>
      <dc:creator>KyleGallagher</dc:creator>
      <dc:date>2010-05-13T18:51:21Z</dc:date>
    </item>
  </channel>
</rss>

