Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to get my head around how multivalues derived from the arcpy command GetParameterAsText gets looped through a script. Could some please provide a sample script that does the follow basic task so that I may study it for further insight?

Get a set of shapefiles from arcpy.GetParameterAsText(0) (the number of shapefiles can vary from to 10 say) and then loop through each shapefile, displaying the following with arcpy.AddMessage saying something to the effect:

"This is shapefile " shapefile name

When looped through all of the shapefiles, print the message "No more shapefiles"

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Is this homework?

for fc in arcpy.GetParameterAsText(0).split(";"):
    arcpy.AddMessage(fc)
arcpy.AddMessage("No more shapefiles")
share|improve this answer
    
LOL. No, not at all. I can see why you would think this though. I just simplified my question as I felt I just needed a nudge on this one issue. Thanks a gazillion. –  user12059 Oct 18 '12 at 15:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.