3.5.2 Known BugsThe following script, executable in ArcView, will "repair" polygon shapefiles created by ARCSHAPE:
' REP352.AVE - repairs polygon shapefiles created by the PC ARC/INFO
' 3.5.2 ARCSHAPE command (polygon island rings are not written with
' identical start and end points). Shapefiles which do not have polygons
' with "islands" need not be processed using this script.
'**** get input and output shapefiles
t1 = "Repair Shapefile"
fnInput = FileDialog.Show("*.shp","Shapefiles",t1)
if (fnInput = nil) then return nil end
inFTab = FTab.Make(fnInput.AsString.AsSrcName)
if (inFTab.GetShapeClass.GetClassName <> "Polygon") then
MsgBox.Error("Shapefile must be polygon.",t1)
return nil
end
fnDefault = FileName.GetCWD.MakeTmp("shape","shp")
fnOutput = FileDialog.Put( fnDefault,"*.shp","Output Shape File" )
if (fnOutput = nil) then exit end
'**** set up output shapefile
fnOutput.SetExtension("shp")
outFTab = FTab.MakeNew( fnOutput, POLYGON )
inFields = inFTab.GetFields
newFields = List.Make
for each f in inFields
if (f.GetName <> "shape") then
newFields.Add(f.Clone)
end
end
outFTab.AddFields(newfields)
'**** do it!
nCount = 0
nRecs = inFTab.GetNumRecords
inSF = inFTab.FindField("shape")
outSF = outFTab.FindField("shape")
for each r in inFTab
nRecNew = outFTab.AddRecord
for each inF in inFTab.GetFields
fName = inF.GetName
if (fName = "shape") then
p1 = inFTab.ReturnValue(inSF,r)
p2 = Polygon.Make(p1.AsPolyLine.AsList)
outFTab.SetValue(outSF,nRecNew,p2)
else
outF = outFTab.FindField(fName)
val = inFTab.ReturnValue(inF,r)
outFTab.SetValue(outF,nRecNew,val)
end
end
nCount = nCount + 1
av.SetStatus((nCount / nRecs) * 100)
end
av.ClearStatus
av.ClearMsg
av.PurgeObjects
MsgBox.Info("Done.",t1)
return nil
Workaround: The SML below works around this in TABLES by adding a temporary character field (XX_TEMPC), populating it with "x", and making that the first sort field.
&rem **** SORT.SML &rem **** sort routine for TABLES for sorting mixed field types &rem **** when the first sort field is numeric &goto usage &if &eq "x%-1" "x" &sv -19 XX_TEMPC &sv -20 ADDITEM %-19 1 C %-20 %-20 MOVE 'x' to %-19 SORT %-19 %-1 %-2 %-3 %-4 %-5 %-6 %-7 %-8 %-9 %-10 %-11 %-12 %-13 %-14 %-15 %-16 %-17 %-18 DROPITEM %-19 Y &return &label usage &type "Usage: &r SORT [item...item]" &returnNOTE: ESRI's current plans for Version 4.0 include dropping TABLES altogether and incorporating its functionality elsewhere (e.g. ARCPLOT). Hopefully the SORT command will also be implemented.
&sv -1 &sv -2 # &type "Before: x%-1x" &type "Before: x%-2x" IDENTITY LINECOV POLYCOV XX LINE &type "After: x%-1x" &type "After: x%-2x"After executing IDENTITY, variable -2 will still contain "#" but -1 will contain 80 spaces. Similarly, local variables in a routine called by a module are filled with spaces:
TABLES tabtest.sml tabtest.sml: &type "x%-1x"Variable -1 will contain 80 spaces.
Workaround: If a variable hasn't been used and a blank value is needed, initialize the variable:
&sv -1 DEFINE [outfile] [item1] 1 C %-1Otherwise, wherever possible, assign a non-blank values:
&if &eq "x%-5" "x" &do &sv -10 # &else &sv -10 %-5 &end IDENTITY [cover1] [cover2] [temp] POLY %-10 INTERSECT [temp] [cover3] [outcover] POLY %-10
Return to
PC ARC/INFO page