In Mapbasic made custom menu selected item to run sub procedure, what i want to make the Sub procedure to be ready to run by selecting an object from the map and run again by selecting another object, and so on


You would need to use the selection handler "SelChangedHandler".

Here is some handy MapBasic code which prints the row ID of each selection, you should be able to adapt it for your own purposes: credits in the header, get it from here

' Mapbasic source code to demonstrate how to get the rowid's of a selection
' Inspired by Mike Katz: Mike.Katz@gmpte.gov.uk
' Written by Uffe Kousgaard: uffe@routeware.dk
' Should be located at http://www.routeware.dk/download/rowid.mb
' 8-Aug-2001

' To use it change the selection in line 20 to something that matches your
' own needs.

include "mapbasic.def"

Declare Sub Main
Declare Sub SelChangedHandler 

dim ID as integer

Sub Main
 dim i as integer
 Set Handler SelChangedHandler Off
 Select * from Mytable where linktype=11 into tmptable
 Set Handler SelChangedHandler On

 print chr$(12)
  for i=1 to tableinfo(tmptable,TAB_INFO_NROWS)
  select * from tmptable where rowid=i
  print ID
 close table tmptable
end program
end Sub

Sub SelChangedHandler
End Sub 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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