Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?



The CALLONEXIT function call allows you to specify the name of a SUBROUTINE to call when the program terminates. The function takes the general form:


Where the subroutine definition would be as:

SUBROUTINE ErrorExit(parm1)

Where Param1 is a parameter passed to the function. It is possible to add parameters to the error subroutine by adding multi-values to the parameter to CALLONEXIT, which are passed to the called subroutine in the first parameter.


If executed multiple times, CALLONEXIT with the same subroutine name, will discard other calls. If executed multiple times with a different subroutine name, then upon exit multiple subroutines will be called in the order that CALLONEXIT was called.

All efforts are made to call the subroutine under all circumstances. However, if a SIGKILL (signal 9) terminates the program, which cannot be trapped, it does not call the subroutine. This is a feature of operating systems, not a limitation. In addition, if the program terminates due to say a memory error, then calling the subroutines depends upon how badly the memory error has corrupted the memory.

The function can be used as follows:

Consider the simple programs below. The program enters the debugger. If at this point the login session terminates for any reason (the line drops, the program is killed, the user enters 'off' at the debugger prompt) , the two specified subroutines (ErrorExit and EndProgram) will still be called just as they would if the program were allowed to terminate normally.

rc = CALLONEXIT("ErrorExit")
rc = CALLONEXIT("EndProgram")

Go back to jBASE BASIC.

Was this article helpful?