Select to view content in your preferred language

Python Output Parameter as String

639
4
01-20-2011 11:51 AM
JMcNeil
Deactivated User
I'm writing this in 9.3.1.  Basically I'm taking in a string and trying to format it for a tool "Select Layer by Attribute".

I'm trying to write a python script to take in a string express, then I'm formatting it and then I'm sending out as a string but I'm having trouble with the output parameter.  Can you tell me what is wrong with my last line and what I need to change.  The line that is giving me trouble is
gp.SetParameterAsText(output)

the error is stating
Running script StringManipulator...
<type 'exceptions.AttributeError'>: Object: Error in parsing arguments for SetParameterAsText
Failed to execute (StringManipulator).

Here's my short script
import sys, string, arcgisscripting
gp = arcgisscripting.create(9.3)
userStr = gp.GetParameterAsText(0)
# userStr = sys.argv(0)
strList = userStr.split(" or ")
output = " or ".join(["\"APN\" = \'%s\'" % (item) for item in strList])
gp.SetParameterAsText(output)
#print output




If you want more background I'm why I'm doing this check out this post. 
http://forums.arcgis.com/threads/210...ed=1#post69372

Thanks
J
0 Kudos
4 Replies
DuncanHornby
MVP Notable Contributor
J,

Are you aware of the AddFieldDelimiters method on the Geoprocessor?

Duncan
0 Kudos
JMcNeil
Deactivated User
Duncan,

Thanks for the reply but I'm not seeing how the AddFieldDelimiters method will help me.  I'm not trying to format a field; I'm trying to format some text that I'm getting from a textbox from my endusers (arcServer).  Not sure if I'm missing something...can I use this method a different way?

J
0 Kudos
DuncanHornby
MVP Notable Contributor
J,

Looking at the Help it says that you need to provide an index position for you output parameter which you are not supplying as shown in your sample code.

Duncan
0 Kudos
JMcNeil
Deactivated User
Duncan,
Thanks! Before I was setting the parameter but that example showed me how to set like


gp.SetParameterAsText(1, output)

Thanks again.

J
0 Kudos