Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Program Halt Component

The Program Halt Component has methods that are called when certain run-time exceptions occur. To make effective use of a program halt component in your application, you can override these methods to control how the exceptions are handled.

For example, you can create a subclass of Program Halt that overrides the _onZeroDivide method:

/* error.class overrides programHalt.class */ 
CLASS sasuser.myclass.error.class extends 
      sashelp.classes.ProgramHalt.class; 
_onZeroDivide:method / (STATE='O'); 
  /*processing goes here */ 
endmethod;
The _onZeroDivide method overrides the method on the parent class and is invoked when a program halt occurs and the ZeroDivide event is sent.

The SCL code that would cause the program halt and send the ZeroDivide event could look like:

import sasuser.myclass.error.class; 
init: 
  dcl num x y; 
  dcl error errorobj = _new_ error(); 
  return; 
main: 
  x=0; 
  y=3/x;
return;

A program halt component enables you to determine whether an application should continue executing or immediately halt execution. This behavior is determined by the value of the stopExecution attribute. (The default is "Yes" to stop program execution.)

Note:   The stopExecution attribute is the only attribute that is editable in a program halt component. All other attributes are set by the component itself.  [cautionend]

The type of error that cause the program halt is stored to the type attribute. The Program Halt Component can trap Generic, Generic Math, Overflow, Underflow, or Zero Divide errors.

The dump attribute stores the list ID of the list that is otherwise displayed in the SAS Log when a program halt occurs. You can use this list to identify problems in your application. For example, you could implement a program halt component and override the error handling methods to send e-mail of the dump when the program halt occurs.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.