I tried the following two things:

 include "mapbasic.def"

 Declare Sub Main
 Declare Sub Exit

Sub Main()

    If WindowInfo(WIN_MAPBASIC, WIN_INFO_OPEN) then
        Close Window WIN_MAPBASIC
    End If

 End Sub


 Sub Exit()
    End Program
 End Sub

But my MapBasic program does not completely exit from MapInfo (close MapInfo).


Let's start by looking at your two statements:

This statement will close the MapBasic Window:


This statement will end your MapBasic application and unload it from memory:

End Program

If you want to shot down MapInfo Professional, you should run this statement:

End MapInfo Interactive

The keyword 'Interactive' makes sure that you are giving the user a chance to save what has not already been saved, either changes to a table or settings to a workspace.

| improve this answer | |

Try Run Menu Command 113. 113 = M_FILE_EXIT in menu.def

| improve this answer | |
  • Thank you for your Input. I tried inserting this line: Run Menu Command 113, in my Mapbasic program and nothing happens. But when I then tried entering the same line in a very short program (with only a Sub Main (): it works. So it looks like I have a problem with my dialog boxes. I tried the following: Dialog Remove with End Mapinfo but then it gives me a "You can't quit Mapinfo" message. – user3405572 Sep 22 '14 at 18:06
  • You can't exit MapInfo from within the handler of a dialog. You'll have to do this after the Dialog statement. You can for example set a modular variable that you can query when the dialog has gone to see if you should End MapInfo or not – Peter Horsbøll Møller Sep 24 '14 at 19:19

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.