Previous posts (such as Adding automated values to attribute field?) answer how to calculate sequential values in an attribute table. The posts all seem to rely on the process described in this ESRI Tech Support page:
Here are the article's details:
- Create a new short integer field.
- Set the Parser to Python.
- Select Show Codeblock.
Paste the following into the Pre-Logic Script Code:
rec=0 def autoIncrement(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec += pInterval return rec
Paste the following code in the smaller box below the Pre-Logic Script Code:
But at 10.5.1 I can achieve the same results with this single line in the field calculator:
!FID! + 1
The results are exactly the same as the more complex ESRI-supplied code, even if the the table is sorted on a non-FID field and/or there is a selected set of records.
What am I missing here? Does the ESRI-supplied code do something that I'm not aware of?