<?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: Counter for While iteration in the model builder in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401441#M13597</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The for syntax is here&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/for.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/for.htm"&gt;For—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and while is here&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/while.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/while.htm"&gt;While—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and there are other iterators within the list. &amp;nbsp;The syntax for why requires a set of inputs and whether to loop until the boolean is either True or False, depending on your choice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Nov 2016 23:07:41 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-11-08T23:07:41Z</dc:date>
    <item>
      <title>Counter for While iteration in the model builder</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401440#M13596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using ArcGis 10.3. I am on the model builder and I have a &lt;STRONG&gt;While&lt;/STRONG&gt; iteration. What I want to do is to create a counter: a variable &lt;EM&gt;x &lt;/EM&gt;which is initialized with the value 1 and add +1 at every run, so the variable x actually shows the number of run.&lt;/P&gt;&lt;P&gt;This is because I want to use that value for saving data with in-line substitution (...%x%...).&lt;/P&gt;&lt;P&gt;You can see attached my first attempt. Basically&amp;nbsp; my &lt;EM&gt;Continue &lt;/EM&gt;is a precondition for &lt;EM&gt; Calculate value (2) &lt;/EM&gt;and the code in it is:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;&lt;CODE&gt;Expression: x("%Continue%")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;def x(n):&lt;BR /&gt;&amp;nbsp;if n== "true":&lt;BR /&gt;&amp;nbsp; x=x+1&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I got this error:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;ERROR 000539: Error running expression: counter("true") &lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 3, in counter&lt;BR /&gt;UnboundLocalError: local variable 'counter' referenced before assignment&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Is there a nicest and easiest way to create a counter?&lt;/P&gt;&lt;P&gt;(Basically the &lt;STRONG&gt;For&lt;/STRONG&gt; iteration has it automatically as the &lt;EM&gt;Value,&lt;/EM&gt; but the &lt;STRONG&gt;While&lt;/STRONG&gt; lacked of a variable which takes account of the run)&lt;EM&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alessandro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Nov 2016 14:04:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401440#M13596</guid>
      <dc:creator>AlessandroSinglitico</dc:creator>
      <dc:date>2016-11-07T14:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Counter for While iteration in the model builder</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401441#M13597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The for syntax is here&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/for.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/for.htm"&gt;For—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and while is here&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/while.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/modelbuilder-toolbox/while.htm"&gt;While—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and there are other iterators within the list. &amp;nbsp;The syntax for why requires a set of inputs and whether to loop until the boolean is either True or False, depending on your choice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Nov 2016 23:07:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401441#M13597</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-11-08T23:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counter for While iteration in the model builder</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401442#M13598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You say that &lt;EM&gt;Calculate value (2)&lt;/EM&gt;&amp;nbsp; has the expression:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;&lt;CODE&gt;Expression: x("%Continue%")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;def x(n):&lt;BR /&gt;&amp;nbsp;if n== "true":&lt;BR /&gt;&amp;nbsp; x=x+1&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But the error message is about &lt;STRONG&gt;counter("true")&lt;/STRONG&gt;? You need to show us the whole model or upload it as a zip file as what you are asking is not clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also look at the help file for the subject &lt;EM&gt;Examples of in-line variable substitution with ModelBuilder system variables&lt;/EM&gt;&amp;nbsp;there are two system variables &lt;STRONG&gt;%i%&lt;/STRONG&gt; and &lt;STRONG&gt;%n%&lt;/STRONG&gt; accessible to you in model builder, may be they are what you are looking for?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2016 13:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401442#M13598</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2016-11-10T13:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Counter for While iteration in the model builder</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401443#M13599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Duncan,&lt;/P&gt;&lt;P&gt;Yes I was actually trying to build a counter to use for in-line substitution. It sounds like&amp;nbsp; the &lt;STRONG&gt;%n%&lt;/STRONG&gt; system variable does all the job, there is no need to build anything.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2016 13:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/counter-for-while-iteration-in-the-model-builder/m-p/401443#M13599</guid>
      <dc:creator>AlessandroSinglitico</dc:creator>
      <dc:date>2016-11-10T13:31:37Z</dc:date>
    </item>
  </channel>
</rss>

