<?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: Using Increments in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-increments/m-p/762264#M58866</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rec=0
def autoIncrement():
&amp;nbsp;&amp;nbsp;&amp;nbsp; global rec
&amp;nbsp;&amp;nbsp;&amp;nbsp; pStart = 10 #adjust start value, if req'd
&amp;nbsp;&amp;nbsp;&amp;nbsp; pInterval = 10
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (rec == 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec = pStart
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec = rec + pInterval
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "{0}".format(rec).zfill(4)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/175264_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:24:17 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-12T08:24:17Z</dc:date>
    <item>
      <title>Using Increments</title>
      <link>https://community.esri.com/t5/python-questions/using-increments/m-p/762263#M58865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In Arc 9.2 I was able to use the following script to calculate incremental numbers;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Tahoma','sans-serif';"&gt;Static rec As Long &lt;BR /&gt; &lt;BR /&gt; Dim lStart As Long &lt;BR /&gt; &lt;BR /&gt; Dim lInterval As Long &lt;BR /&gt; &lt;BR /&gt; Dim i As Integer &lt;BR /&gt; &lt;BR /&gt; Dim iStringLength As Integer &lt;BR /&gt; &lt;BR /&gt; Dim sID As String &lt;BR /&gt; &lt;BR /&gt; '============================ &lt;BR /&gt; &lt;BR /&gt; 'set the variables below &lt;BR /&gt; &lt;BR /&gt; iStringLength = 7 &lt;BR /&gt; &lt;BR /&gt; lStart = 0001 &lt;BR /&gt; &lt;BR /&gt; lInterval = 1 &lt;BR /&gt; &lt;BR /&gt; '============================ &lt;BR /&gt; &lt;BR /&gt; sID = "" &lt;BR /&gt; &lt;BR /&gt; If (rec = 0) Then &lt;BR /&gt; &lt;BR /&gt; rec = lStart &lt;BR /&gt; &lt;BR /&gt; Else &lt;BR /&gt; &lt;BR /&gt; rec = rec + lInterval &lt;BR /&gt; &lt;BR /&gt; End If &lt;BR /&gt; &lt;BR /&gt; For i = 1 To iStringLength - Len(CStr(rec)) &lt;BR /&gt; &lt;BR /&gt; sID = sID &amp;amp; "0" &lt;BR /&gt; &lt;BR /&gt; Next i &lt;BR /&gt; &lt;BR /&gt; sID = sID &amp;amp; CStr(rec) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Tahoma','sans-serif';"&gt;In Arc 10.2, am I right in saying that I can no longer use this script? I've tried the posted python example of;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rec=0&lt;/P&gt;&lt;P&gt;def autoIncrement():&lt;/P&gt;&lt;P&gt; global rec&lt;/P&gt;&lt;P&gt; pStart = 1 #adjust start value, if req'd &lt;/P&gt;&lt;P&gt; pInterval = 1 #adjust interval value, if req'd&lt;/P&gt;&lt;P&gt; if (rec == 0): &lt;/P&gt;&lt;P&gt;&amp;nbsp; rec = pStart &lt;/P&gt;&lt;P&gt; else: &lt;/P&gt;&lt;P&gt;&amp;nbsp; rec = rec + pInterval &lt;/P&gt;&lt;P&gt; return rec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is fine, to a degree but not the results I'm truly looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking to populate a 4 character field with leading zeros as well as incrementing by 10 each new record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg; 0010, 0020, 0030, etc up to a possible 9990.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone able to help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Tahoma','sans-serif';"&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Feb 2016 16:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-increments/m-p/762263#M58865</guid>
      <dc:creator>JonathanMcDougall</dc:creator>
      <dc:date>2016-02-01T16:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using Increments</title>
      <link>https://community.esri.com/t5/python-questions/using-increments/m-p/762264#M58866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rec=0
def autoIncrement():
&amp;nbsp;&amp;nbsp;&amp;nbsp; global rec
&amp;nbsp;&amp;nbsp;&amp;nbsp; pStart = 10 #adjust start value, if req'd
&amp;nbsp;&amp;nbsp;&amp;nbsp; pInterval = 10
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (rec == 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec = pStart
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rec = rec + pInterval
&amp;nbsp;&amp;nbsp;&amp;nbsp; return "{0}".format(rec).zfill(4)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/175264_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-increments/m-p/762264#M58866</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T08:24:17Z</dc:date>
    </item>
  </channel>
</rss>

