Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This may seem relatively simple, but I'm pretty confused. I have written a mapbasic tool that does things to the table 'Selection' depending on user choices in a popup menu, but currently you need to use the select too to select an item and then run the program. I was wondering how I'd go about selecting an object with a click then it instantly running the main part of the tool?

Thanks, Alan

share|improve this question
I have modified the code in the MapBasic reference guide (as I will only be working with points), however I've gone wrong somewhere as when I click on any point it selects all points in the table! Here is what I have: – Alan Carr May 21 '13 at 14:13
up vote 1 down vote accepted

Build your SQL statement at runtime:

comm = "Select * from "+s_table+" where rowid ="+i_row_id+" into Selection" 
Run Command comm
share|improve this answer
Thanks! Works great! – Alan Carr May 22 '13 at 16:11

Or just:

Select * from s_table 
   Where rowid = i_row_id 
   into Selection  
share|improve this answer
I'm thinking that this was probably intended as a Comment on another Answer rather than an Answer in its own right. – PolyGeo May 23 '13 at 8:28
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – PolyGeo May 23 '13 at 8:29
Well, my answer is another of doing it. The first answer does it using a string built at runtime but it can also be done using a select statement without involving the Run Command statement – Peter Horsbøll Møller May 23 '13 at 10:12
My apologies - I'm not sure where that second comment attributed to me came from but it seems to have been system generated - and I don't think the first (somewhat similar) Answer was there when I reviewed yours and thought it was out of context. By way of apology I'll upvote your answer. – PolyGeo May 23 '13 at 10:34
Thanks, PolyGeo – Peter Horsbøll Møller May 24 '13 at 7:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.