Reference Manual - Table of Contents

Execution Control
Forms and Windows
Controls
Menus
System and Desktop
Graphic Drawing Commands

Animation
QuickTime Movies
Speech
Sound
File I/O
Printing
Serial Ports

Math Functions
String Functions
Date and Time
Memory Buffers
Error Handling
Console Text Window

Events

Direct Memory Access
Direct Mouse Access
Direct Keyboard Access
Code Resource Modules

A - Runtime Error Messages
B - Compiler Error Messages

Error Handling

The commands and functions described in this section describe what can be done when a application created in Visual MacStandardBasic encounters an error when executing. See Appendix A and Appendix B for a listing of runtime and compiler error messages.

 

Command Summary:
OnError Sub

Function Summary:
var = ErrorNum( )
var$ = ErrorMsg ( )

 

OnError Sub

This command is used to call a Sub procedure if an error occurs. Normally when an error occurs an alert message box will be displayed showing the error # and message. Once the user acknowledges it by clicking on the OK command button, the application terminates.

By using the OnError command to call a Sub procedure instead the alert message box is not displayed. The Sub procedure called is responsible for handling the error. You can use the ErrorNum and ErrMsg functions to determine what error has occurred.

var = ErrorNum( )

This function returns the number of the last error.

 

var$ = ErrorMsg( )

This function returns a text string that is the error message of the last error.