taged code in forums introduce spaces in the text?

3959
3
08-04-2010 08:48 AM
ChrisSnyder
Regular Contributor III
I have been noticing that when you apply a code tag in the forums, sometimes random spaces are introduced in the taged code. I don't think this is user error, since I have seen it more than a few times. For example the post here: http://forums.arcgis.com/threads/9559-Python-if-...-then-Statement

conatains:

Contours = "\\\\Atlas\\data\\geodata\\state\\contour\\arc "
Crossings = "\\\\Atlas\\data\\geodata\\state\\crossings\\a rc"
Contour = "Contour.shp"
Crossing = "Crossing.shp"
P_L = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\La mberts_Projection\\Pts_Lines"
Clip_Feature = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature\\Clip_Feature.shp"

I have noticed this weird placement of random spaces in the code tags of several other posts as well, for example:
http://forums.arcgis.com/threads/9512-Rectangle-for-Clip_management-tool-in-arcpy

Code with random spaces introduced to it is lame...

P.S. Funny thing I noticed is that when composing this message, the last line of the Python code above contained no spaces, but when I preview it, there is a space in "Cl ip". This space wasn't there when I composed the message - see the attached screen shot image for proof. Seems like it's not just tagged code that is affected? Perhaps this is another sympom of using IE8?
0 Kudos
3 Replies
ChrisSnyder
Regular Contributor III
Woops, I guess it's not the tagged code at all, just the raw text that is affected. Anyway, it's weird that there are spaces! Maybe something to do with the line wrapping?
0 Kudos
by Anonymous User
Not applicable
Original User: jbarry

Thanks Chris.

I'll test a few things, browsers, versions, line lengths, etc. and see if I can figure this out.   Of course we shouldn't be adding or removing extra spaces or characters, etc.

Until then, at least for code samples, you might like using the CODE blocks for this.  (Tool button on the text editor with the # symbol on it.) 

For example, does this below look ok to you?

%%%%%%%%%%
%    TEST BELOW
%%%%%%%%%%


In your script does the first line restrict the loop to only the reference layer? I need the If statement to look at the referred layer only as there is a master layer in the same directory that would have 'Murray Inland'. This script is part of a geoprocessor model where the 'clip feature' is derived from user input. I have also noticed the 'while' loop significantly increases processing time. Could a 'for' loop be used instead of 'while'?

The loop I'm attempting is:

fieldname = "Region"
gp.workspace = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature"
shp = gp.ListFeatureClasses()
for shp in shp:
if fieldname == 'Murray Inland':
gp.Delete_management("C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Lamberts_Projection\\Pts_Lines\\Contour.shp")
This loop has the problem of not being specific to the 'clip feature' layer and also looks at the master layer.

I have attempted to run the supplied while loop script which executes successfully but gives an error that the contour layer does not exist.

My complete script is shown below:

import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)

Contours = "\\\\Atlas\\data\\geodata\\state\\contour\\arc "
Crossings = "\\\\Atlas\\data\\geodata\\state\\crossings\\arc"
Contour = "Contour.shp"
Crossing = "Crossing.shp"
P_L = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Lamberts_Projection\\Pts_Lines"
Clip_Feature = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature\\Clip_Feature.shp"

gp.FeatureClassToFeatureClass_conversion(Contours, P_L, Contour, "")
gp.FeatureClassToFeatureClass_conversion(Crossings , P_L, Crossing, "")

gp.workspace = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature"
scursor=gp.SearchCursor(Clip_Feature)
row=scursor.Next()
while row:
if row.GetValue("Region") == 'Murray Inland':
gp.Delete_management("C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Lamberts_Projection\\Pts_Lines\\Contour.shp")
del scursor 
0 Kudos
ChrisSnyder
Regular Contributor III
Jim,

That test looks fine to me (no random spaces). Seems like the issue is when users paste text into the message body. My assertion that it was the code tag was wrong. Must be a dyslexic day toady...
0 Kudos