Purpose
Halts a MapBasic application.
Restrictions
The End Program statement may not be issued from the MapBasic window.
Syntax
End Program
Description
The End Program statement halts execution of a MapBasic program. A MapBasic application can add items to MapInfo Pro menus, and even add entirely new menus to the menu bar. Typically, a menu item added in this fashion calls a sub procedure from a MapBasic program. Once a MapBasic application has connected a procedure to the menu in this fashion, the application is said to be "sleeping."
If any procedure in a MapBasic application issues an End Program statement, that entire application is halted―even if "sleeping" procedures have been attached to custom menu items. When an application halts, MapInfo Pro automatically removes any menu items created by that application.
If an application defines a procedure named EndHandler, MapBasic automatically calls that procedure when the application halts, for whatever reason the application halts.
Interpreted Mode
While executing a MapBasic script in the interpreted mode (which does not support conditionals like the "if" statement), you need a way to stop the script. To achieve this, you can now use the End Program statement in the interpreted mode:
End Program [Condition(expr)] ' The Condition clause is optional
expr is a boolean (logical) expression. If True, the execution of the script text is stopped. If False, the execution continues.
print "before"
fetch first from usa
End Program Condition(usa.State="AL")
print "after"
If the first state is AL, then the print "after" statement will not be executed.
See Also:
End MapInfo statement, EndHandler procedure