I'm trying to code the names from geo database the total records of names are 957 and i want each name to have the uniqueID and it should not exceed three digits. starting from 001.
The below script started from 101 which now is giving me a problem when i rich to one thousand because it gives me the four digits.
I have been using the below Script to code names but unfortunately i'm now stuck because some ID'S are now having four digits.
rec=0
def autoIncrement():
global rec
pStart =101
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec += pInterval
return rec
Here is the steps to code,
Right-Click on Field Calculator Set the Parser to Python (Default is usually VB) Tick Show Codeblock.
Paste the following into the Pre-Logic Script Code
rec=0
def autoIncrement():
global rec
pStart =101
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:
autoIncrement()
Click OK.
{}
on the toolbar that allows you to format code blocks. Since python is a space sensitive language, doing this helps eliminate the possibility that you're not indenting lines properly. – Branco Nov 24 '15 at 13:30