Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

AddMessage question

$
0
0
How would you do this using AddMessage instead of print and in a script tool? My code has a parameter and where_clause in the search cursor so the user inputs a name and I would like a message listing field values.

ESRI expample:

Code:

import arcpy
# Open a searchcursor
#  Input: C:/Data/Counties.shp
#  Fields: NAME; STATE_NAME; POP2000
#  Sort fields: STATE_NAME A; POP2000 D
rows = arcpy.SearchCursor("c:/data/counties.shp",
                          fields="NAME; STATE_NAME; POP2000",
                          sort_fields="STATE_NAME A; POP2000 D")

# Iterate through the rows in the cursor and print out the
# state name, county and population of each.
for row in rows:
    print("State: {0}, County: {1}, Population: {2}".format(
        row.getValue("STATE_NAME"),
        row.getValue("NAME"),
        row.getValue("POP2000")))


Viewing all articles
Browse latest Browse all 2485

Trending Articles