AnsweredAssumed Answered

if then problem

Question asked by soatley on Feb 8, 2011
Latest reply on Feb 8, 2011 by soatley
Hi Folks,

Running the following script (arcgis 10):
import arcpy
import sys

longitude, latitude = sys.argv[1], sys.argv[2]

arcpy.AddMessage("Longitude: " + longitude + " Latitude: " + latitude)

if longitude < -100:
    #arcpy.AddMessage("Longitude < -100")
    print "Longitude < -100"
else:
    #arcpy.AddMessage("Longitude > -100")
    print "Longitude > -100"


Gets this result in the output window:
Executing: ifthen -101 50
Start Time: Tue Feb 08 14:52:26 2011
Running script ifthen...
Longitude: -101 Latitude: 50
Longitude > -100
Completed script ifthen...
Succeeded at Tue Feb 08 14:52:28 2011 (Elapsed Time: 2.00 seconds)


And ...

Executing: ifthen -99 50
Start Time: Tue Feb 08 14:53:49 2011
Running script ifthen...
Longitude: -99 Latitude: 50
Longitude > -100
Completed script ifthen...
Succeeded at Tue Feb 08 14:53:50 2011 (Elapsed Time: 1.00 seconds)


The if-then result is the same no matter what the value of longitude.

Yet, if I manually set a value for longitude in the python window, I can swap out the AddMessage statements with the print statements, paste the if-then into the python window, and it runs correctly.

What am I missing???

Thanks,
Scott

Outcomes