Run-time errors

Run-time errors are generated when execution of a particular code statement or function results in an error condition being set.  Run-time errors caught by PowerBASIC include Disk access violations (i.e., trying to write data to a full disk), out of bounds array and pointer access, and Memory allocation failures.  Array bounds and null-pointer checking is only performed when #DEBUG ERROR ON is used.

Run-time errors can be trapped; that is, you can cause a designated error-handling subroutine to get control should an error occur.  Use the ON ERROR statement to accomplish this.  This routine can "judge" what to do next based on the type of error that occurs.  File-system errors (for example, disk full) in particular are prime candidates for run-time error-handling routines.  They are the only errors that a thoroughly debugged program should have to deal with.

The ERROR statement (which simulates run-time errors) can be used to debug your error-handling routines.  It allows you to deliberately cause an error condition to be flagged.  Avoid using error numbers higher than 240, as they are reserved for use in critical error situations which can never be trapped with ON ERROR.

In the situation where an undocumented run-time error occurs, the chief suspect is memory corruption.  This can typically be cause by writing beyond an array boundary, improper use of pointers, bad Inline Assembly code, etc.

 

See Also

Error Overview

Compile-time errors

Disk Errors

Error Trapping