Oh, it's worse than that.  

Not only does a SELECT call your own SelChangedHandler, it also calls the
SelChangedHandler of any other sleeping MapBasic app that happens to be
loaded.  You can disable your own SelChangedHandler with a Set Handler
statement but not any of the others.

When issuing SELECT statements within your own code, always add an INTO
clause with NOSELECT to the end.  A SELECT with NOSELECT merely selects
records; it doesn't change MapInfo's internal "selection" table and doesn't
trigger calls to all those SelChangedHandlers.

The only time you want to omit NOSELECT is when you want the selected
records to appear selected on the screen.

Of course, to use NOSELECT, you need to come up with a table name for the
INTO clause.  Most people use a hardcoded table name but there's always a
possibility that the user will open a table with precisely that name.  The
other problem is that you always create a query table, regardless of whether
any records are selected or not.

For my own work, I wrote a module named NSQUERY that abstracts the creation
of a scratch table name (similar to MapInfo's "Queryx" scheme) and runs all
of the SELECT statements with Run Command.  If records are returned, the
routine returns the scratch name; otherwise, it closes the table and returns
an empty string. I imagine it's slightly slower than just emitting the
statement inline with a hard-coded name, but that's outweighed by the
benefit of catching and logging errors without crashing the app.

HTH
Spencer



-----Original Message-----
From: Nicki Cozens [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 31, 2006 3:14 AM
To: Spencer Simpson; [email protected]
Subject: RE: [MI-L] Help with commandinfo(CMD_INFO_ROWID) after a dialog
iscalled please

Thanks Spencer for your advice.  Can I check if I have understood
something correctly?  :-} 

I have a lot of other selections that happen within the SnapNodes code,
if I use the SelChangedHandler, will this mean that it will run each
time a selection is made?  I am worried that this might slow down the
code considerably.  

Regards
Nicki



-----Original Message-----
From: Spencer Simpson [mailto:[EMAIL PROTECTED] 
Sent: 30 August 2006 20:35
To: Nicki Cozens; [email protected]
Subject: RE: [MI-L] Help with commandinfo(CMD_INFO_ROWID) after a dialog
iscalled please

CommandInfo (CMD_INFO_ROWID) should only be used within a
SelChangedHandler,
and only when CommandInfo (CMD_INFO_SELTYPE) returns 1 or 2.   

You want to manipulate the entire table aSelName rather than one row of
the
base table.  Alternatively, store the return value form CommandInfo
(CMD_INFO_ROWID) in a variable in SelChangedHandler, and then use its
value
in SnapNodes.

HTH
Spencer

________________________________________


_______________________________________________________________________
Leicestershire County Council - rated a  'four-star' council by the Audit
Commission
_______________________________________________________________________


This e-mail and any files transmitted with it are confidential. If you are
not the intended recipient, any reading, printing, storage, disclosure,
copying or any other action taken in respect of this e-mail is prohibited
and may be unlawful. If you are not the intended recipient, please notify
the sender immediately by using the reply function and then permanently
delete what you have received.

Incoming and outgoing e-mail messages are routinely monitored for compliance
with Leicestershire County Council's policy on the use of electronic
communications.   The contents of e-mails may have to be disclosed to a
request under the Data Protection Act 1998 and the Freedom of Information
Act 2000.

The views expressed by the author may not necessarily reflect the views or
policies of the Leicestershire County Council.

Attachments to e-mail messages may contain viruses that may damage your
system. Whilst Leicestershire County Council has taken every reasonable
precaution to minimise this risk, we cannot accept any liability for any
damage which you sustain as a result of these factors. You are advised to
carry out your own virus checks before opening any attachment.





_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to