import arcgisscripting, sys, os, string, traceback
gp = arcgisscripting.create(9.3)
# Set to write over previous outputs if they exist
gp.overwriteoutput = False
def which30(two6ftrcls):
two6FC = two6ftrcls
whereclause = "Two6FCs = '" + two6FC + "'"
gp.AddMessage("whereclause is " +whereclause)
crosswalk = ShellPath + "/Two630FC_IDPKxwalk.dbf"
# The variables row and rows are initially set to None, so that they
# can be deleted in the finally block regardless of where (or if)
# script fails.
row, rows = None, None
Three0ftrlst = []
FC_26namelst = []
row, rows = None, None
Three0ftrlst = []
FC_26namelst = []
rows = gp.SearchCursor(crosswalk,whereclause)
row = rows.next()
if (row == None):
gp.AddMessage("check the Two630FC_IDPKxwalk.dbf table for Two6FCs -->" +two6FC)
elif (row != None):
while row:
if not row.isNull("Three0FCs"):
Three0ftr=row.getValue("Three0FCs")
gp.AddMessage("Three0ftr is " +Three0ftr)
Three0ftrlst.append(str(Three0ftr))
FC_26name = row.getValue("FC_26")
FC_26namelst.append(str(FC_26name))
row = rows.next()
if row: del row
if rows: del rows
return Three0ftrlst, FC_26namelst
row=rows.next() while row: code.... row=rows.next()
import arcgisscripting, sys, os, string, traceback
gp = arcgisscripting.create(9.3)
# Set to write over previous outputs if they exist
gp.overwriteoutput = False
def which30(two6ftrcls):
two6FC = two6ftrcls
whereclause = "Two6FCs = '" + two6FC + "'"
gp.AddMessage("whereclause is " +whereclause)
crosswalk = ShellPath + "/Two630FC_IDPKxwalk.dbf"
# The variables row and rows are initially set to None, so that they
# can be deleted in the finally block regardless of where (or if)
# script fails.
row, rows = None, None
Three0ftrlst = []
FC_26namelst = []
row, rows = None, None
Three0ftrlst = []
FC_26namelst = []
rows = gp.SearchCursor(crosswalk,whereclause)
if (row == None):
gp.AddMessage("check the Two630FC_IDPKxwalk.dbf table for Two6FCs -->" +two6FC)
elif (row != None):
for row in rows:
if not row.isNull("Three0FCs"):
Three0ftr=row.getValue("Three0FCs")
gp.AddMessage("Three0ftr is " +Three0ftr)
Three0ftrlst.append(str(Three0ftr))
FC_26name = row.getValue("FC_26")
FC_26namelst.append(str(FC_26name))
if row: del row
if rows: del rows
return Three0ftrlst, FC_26namelst
With help from the forum, I thought I figured out how to write a cursor to work in 9.3 and 10 but users report not.
import arcgisscripting
gp = arcgisscripting.create(9.3)
try:
rows = gp.SearchCursor(crosswalk,whereclause)
row = rows.next()
if not row:
gp.AddError("check the Two630FC_IDPKxwalk.dbf table for Two6FCs -->" +two6FC)
raise
while row:
# do row stuff...
row = rows.next()
except:
raise
finally:
del row, rowsrows = arcpy.SearchCursor(crosswalk,whereclause) for row in rows: # do row stuff