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: firstname.lastname@example.org ' 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 next close table tmptable end program end Sub Sub SelChangedHandler ID=CommandInfo(CMD_INFO_ROWID) End Sub