RE: [MI-L] Suppressing warning Messages in MapBasic

359 views
Skip to first unread message

Thomas Bacon

unread,
Feb 12, 2013, 9:38:02 AM2/12/13
to mapi...@googlegroups.com

Hi Steve,

 

You can ignore it by using the ‘OnError’ and ‘Resume ‘ statements to handle the error.  Alternatively (and a much better option in my opinion) you could select only records which have an associated map object and then run your update on the selection (see code below). This *should* avoid the error entirely (no promises!).

 

'===================================================

ALTER TABLE "HFSVs_Completed_2008_09" ( add Easting Integer ) INTERACTIVE

ALTER TABLE "HFSVs_Completed_2008_09" ( add Northing Integer ) INTERACTIVE

Select * from HFSVs_Completed_2008_09 where Obj into ToUpdate

UPDATE ToUpdate Set Easting = CentroidX(obj)

UPDATE ToUpdate Set Northing = CentroidY(obj)

COMMIT TABLE HFSVs_Completed_2008_09 INTERACTIVE

CLOSE TABLE HFSVs_Completed_2008_09 INTERACTIVE

'===================================================

 

Hope this helps!

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

 

From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of StevePeat
Sent: 12 February 2013 14:21
To: mapi...@googlegroups.com
Subject: [MI-L] Suppressing warning Messages in MapBasic

 

Hi, Does anyone know of a way to supress warning messages when running command scripts in the MapInfo MapBasic Window. I am running a simple script on multiple table, part of which contains the commands

 

OPEN TABLE "\\Hqgis\Planweb\Public\Community Fire Safety\Prevention\STATIC\2008-09\HFSVs Completed 2008-09.TAB" INTERACTIVE

ALTER TABLE "HFSVs_Completed_2008_09" ( add Easting Integer ) INTERACTIVE

ALTER TABLE "HFSVs_Completed_2008_09" ( add Northing Integer ) INTERACTIVE

UPDATE HFSVs_Completed_2008_09 Set Easting = CentroidX(obj)

UPDATE HFSVs_Completed_2008_09 Set Northing = CentroidY(obj)

COMMIT TABLE HFSVs_Completed_2008_09 INTERACTIVE

CLOSE TABLE HFSVs_Completed_2008_09 INTERACTIVE

OPEN TABLE "\\Hqgis\Planweb\Public\Community Fire Safety\Prevention\STATIC\2008-09\HFSVs Completed 2008-09.TAB" INTERACTIVE

 

On some tables, when it gets to the UPDATE statements, they work as desired, but issue the MapInfo warning "CentroidX: could not fetch object from the current row, argument 1" , and the script stops.

I simply want it to ignore the error and carry on

I have tried using the SET PROGRESSBARS OFF andSET EVENT PROCESSING OFF statements but these have no effect 

Thanks

Steve Peat

Devon and Somerset Fire and Rescue Service, UK

 

 

 

 

 

 

 

 

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
 
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



Mouchel logo

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

Bill Thoen

unread,
Feb 12, 2013, 11:43:56 AM2/12/13
to mapi...@googlegroups.com
I remember having some trouble with that approach. It seems that MapBasic's On Error didn't trap warnings; just errors. Eventually what I had to do was find out what was wrong with the records that were throwing warnings and fix it befoer it got to the critical step. In my case the problems all had to do with  topology (or lack of it) so that meant running snap and thin and clean operations on the polygons first.

Tony Pilkington

unread,
Feb 12, 2013, 5:17:44 PM2/12/13
to mapi...@googlegroups.com
Steve, one of the techniques Bill mentioned many blue moons ago to evade a warning was to use a safe statement like:
redim a(n+1)
immediately before (or after, I can’t remember which) a geometry adjustment statement. This had the effect of failing to trigger a warning when the geometry statement produced a dodgy end product. Bill can probably advise.
 
Tony

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2897 / Virus Database: 2639/6097 - Release Date: 02/11/13

Bill Thoen

unread,
Feb 12, 2013, 6:55:06 PM2/12/13
to mapi...@googlegroups.com
Oh yes.... I remember that! It was a kludge, but it was short and reliable and worked well.  It was many moons ago and since I've got a memory like a steel sieve I've forgotten the details. But I think I got that tip from Eric B.  Also, I think that's documented in the MapBasic knowledge base. (I just looked but couldn't find it.)

StevePeat

unread,
Feb 13, 2013, 4:12:01 AM2/13/13
to mapi...@googlegroups.com
Tony, Bill, Tom,
Many thanks for your replys. Am relatively new to this product, and just starting to understand the restrictions as to what can be entered into the MapBasic Window (I don't think we are licensed for the compiler version), hence the onerror/resume method cannot be used, however the suggested change to the code from Tony has done the trick, so many thanks for that
Regards
Steve

On Tuesday, 12 February 2013 14:21:18 UTC, StevePeat wrote:

Eric Blasenheim

unread,
Feb 13, 2013, 5:44:40 AM2/13/13
to mapi...@googlegroups.com
A few comments.
 
The interactive keyword, Steve, means that you want messages to be displayed in the UI. If you don't leave off interactive.
The MapBasic compiler is free but may not match your version of Professional. 
I am not sure what some very smart folks on this list are referring to when they mention "warning". Technically, there are no warnings in Mapbasic. A command either succeeds or fails and that can be trapped in a program. 
 
A "could not fetch..." is not a warning but an error. To avoid asking Professional to get a centroid on a record that has no geometry, first query the table where  Obj exists (select ... where obj) and then use that result for updating.
 
Eric Blasenheim
Pitney Bowes Software

bill thoen

unread,
Feb 13, 2013, 5:43:38 PM2/13/13
to mapi...@googlegroups.com

The compiler is free. Anybody can download it and use it.

Reply all
Reply to author
Forward
0 new messages