#test number if myCountOfObjects < myMinimum: #gp.AddError("The input should be more than " + str(myMinimum) +" objects and is currently " + str(myCountOfObjects)) #print "The input should be " + str(myMinimum) +" or more objects and is currently " + str(myCountOfObjects) raise RuntimeError("The input should be " + str(myMinimum) +" or more objects and is currently " + str(myCountOfObjects)) #sys.exit(0) elif myCountOfObjects > myMaximum: #gp.AddError("The input should be less than " + str(myMaximum) +" objects and is currently " + str(myCountOfObjects)) #print "The input should be " + str(myMaximum) + " or less objects and is currently " + str(myCountOfObjects) raise RuntimeError("The input should be " + str(myMaximum) + " or less objects and is currently " + str(myCountOfObjects)) #sys.exit(0) else: gp.AddMessage("Processing " + str(myCountOfObjects) + " objects") print "Processing " + str(myCountOfObjects) + " objects"
Don't use sys.exit, in the past its given random results. Instead you should raise an exception, then ArcGIS will note the error.
I modified your code block:#test number if myCountOfObjects < myMinimum: #gp.AddError("The input should be more than " + str(myMinimum) +" objects and is currently " + str(myCountOfObjects)) #print "The input should be " + str(myMinimum) +" or more objects and is currently " + str(myCountOfObjects) raise RuntimeError("The input should be " + str(myMinimum) +" or more objects and is currently " + str(myCountOfObjects)) #sys.exit(0) elif myCountOfObjects > myMaximum: #gp.AddError("The input should be less than " + str(myMaximum) +" objects and is currently " + str(myCountOfObjects)) #print "The input should be " + str(myMaximum) + " or less objects and is currently " + str(myCountOfObjects) raise RuntimeError("The input should be " + str(myMaximum) + " or less objects and is currently " + str(myCountOfObjects)) #sys.exit(0) else: gp.AddMessage("Processing " + str(myCountOfObjects) + " objects") print "Processing " + str(myCountOfObjects) + " objects"
This would give you the proper effect you are looking for.
myCountOfObjects = int(gp.GetParameterAsText(0)) myMinimum = int(gp.GetParameterAsText(1)) myMaximum = int(gp.GetParameterAsText(2))