0% found this document useful (0 votes)
48 views

Runtime Error Behavior: Using The Development Environment

This document discusses runtime errors in programs and how to debug programs using MapBasic. There are two main types of errors: compilation errors which prevent programs from running and runtime errors which occur when a program is executed. Runtime errors happen due to conditions that exist when the program runs and may cause MapInfo to halt execution and display an error message identifying the file, line number, and type of error. Developers can use debugging tools like Stop statements in MapBasic to identify where problems are occurring in programs.

Uploaded by

nguyenhavnptorg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Runtime Error Behavior: Using The Development Environment

This document discusses runtime errors in programs and how to debug programs using MapBasic. There are two main types of errors: compilation errors which prevent programs from running and runtime errors which occur when a program is executed. Runtime errors happen due to conditions that exist when the program runs and may cause MapInfo to halt execution and display an error message identifying the file, line number, and type of error. Developers can use debugging tools like Stop statements in MapBasic to identify where problems are occurring in programs.

Uploaded by

nguyenhavnptorg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Runtime Error Behavior

Runtime Error Behavior


There are two main types of programming errors: compilation errors and runtime errors. Compilation
errors, discussed in Using the Development Environment, are syntax errors or other
typographical mistakes that prevent a program from compiling successfully.

Runtime errors are errors that occur when the user actually runs an application. Runtime errors
occur for various reasons; often, the reason has to do with precise conditions that exist at runtime.
For example, the following statement compiles successfully:

Map From stats


However, if there is no table named “stats,” this program generates a runtime error. When a runtime
error occurs, MapInfo Professional halts the MapBasic application, and displays a dialog box
describing the error.

The error message identifies the name of the program file and the line number at which the error
occurred. In the example above, the name of the program is map_it, and the line number containing
the error is 16. This line number identifies which part of your program caused the runtime error.
Once you know the line number, you can return to the MapBasic development environment and use
the Go To Line command (on the Search menu) to locate the statement that caused the problem.

Debugging a MapBasic Program


Some runtime errors are easy to correct. For example, some runtime errors can be caused by
modest typing errors (for example, in the example above, the programmer probably meant to enter
the table name as STATES instead of STATS). Other errors, however, can be harder to locate. To
help you detect and correct bugs in your program, MapBasic provides debugging tools (the Stop
and Continue statements) which work in conjunction with MapInfo Professional’s MapBasic
Window.

Summary of the Debugging Process


If part of your program is not working correctly, you can use the following procedure to identify where
the problem occurs:

1. Within the MapBasic development environment, edit your program, and place a Stop statement
just before the part of your program that seems to be failing.

2. Recompile and run your program.


When your program reaches the Stop statement, MapBasic temporarily suspends execution of
your program and displays a debugging message in the MapBasic window (for example,
“Breakpoint at textbox.mb line 23").

78 MapBasic 11.5

You might also like