Hi Sean
I got this response from Bill, one of the MapInfo Pro developers back in December but never got to posting it here. Sorry about that.
I tried this out and it does not crash and the error (actually a warning of sorts - even though MIPro does not have warnings) is trapped and resumed.
Code provided below.
Error is likely coming from the call to debug(), which he did not provide, so it's commented out here.
Include "MapBasic.def"
declare sub main
declare function generalize() as logical
sub main
onerror goto Errortrap
Open table ApplicationDirectory$() & "AnnArbor.tab"
Map from AnnArbor
Select * from AnnArbor
if generalize() = TRUE then
note "Thinned"
else
note "Failed"
end if
exit sub
Errortrap:
note "Main: " & Err() & ": " & Error$()
resume next
end sub
function generalize() as logical
dim rc as logical
onerror goto recover
rc = false
'call debug("smoothing")
Create Object As Union From Selection Into Table Cosmetic1
Objects Snap From Selection Tolerance Node 50 Vector 50 Units "m" Thin Bend 50 Distance 50 Units "m"
rc = true
generalize = rc
exit function
recover:
note "generalize: " & Err() & ": " & Error$()
resume next
end function
Let us know if this helps you out
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 12-02-2020 14:00
From: Sean Loos
Subject: MapBasic "Objects Snap" warning crashes MBX
I am trying to use Objects Snap to thin nodes from polygons in MapBasic, and when small islands/holes in the polygon will be removed I get an error message:
(code.mb:1354) Warning: Object(s) removed during Thin operation.
The objects are correctly thinned, but the .MBX crashes at this point, even with an onerror -> resume next. My function operates on the current selection. I have attached a table with a polygon that leads to the problem. Here is my function:
function generalize() as logical
dim rc as logical
onerror goto recover
rc = false
call debug("smoothing")
Create Object As Union From Selection Into Table Cosmetic1
Objects Snap From Selection Tolerance Node 50 Vector 50 Units "m" Thin Bend 50 Distance 50 Units "m"
rc = true
generalize = rc
exit function
recover:
resume next
end function
Any thoughts on how to avoid / trap the warning without crashing? Thanks!
------------------------------
Sean Loos
MAPPING SOLUTIONS
------------------------------