Previous: 4.67.1.8. ExeSize variable To the Table of Contents Next: 4.67.1.10. ExitProc variable
4.67.1.8. ExeSize variable Table of Contents 4.67.1.10. ExitProc variable

- 4.67.1.9. -
Table of Contents
4. Standard Units
4.67. System - Built-in routines
4.67.1. System Unit Variables
4.67.1.9. ExitCode variable


4.67.1.9. ExitCode variable

Targets: MS-DOS, OS/2, Win32

System Unit

ExitProc, ExitCode, and ErrorAddr variables are used to implement exit procedures.

The ExitProc pointer variable allows one to install an exit procedure. The exit procedure always gets called as part of a program's termination.

An exit procedure takes no parameters and must be compiled with a far procedure directive to force it to use the far call model.

When implemented properly, an exit procedure actually becomes part of a chain of exit procedures. The procedures on the exit chain get executed in reverse order of installation.

To keep the exit chain intact, you must save the current contents of ExitProc before changing it to the address of your own exit procedure.

The first statement in your exit procedure must reinstall the saved value of ExitProc.

An exit procedure may learn the cause of termination by examining the ExitCode integer variable and the ErrorAddr pointer variable. The last exit procedure (the one installed by the run-time library) closes the Input and Output files. If ErrorAddr is not nil, it outputs a run-time error message.


Previous: 4.67.1.8. ExeSize variable To the Table of Contents Next: 4.67.1.10. ExitProc variable
4.67.1.8. ExeSize variable Table of Contents 4.67.1.10. ExitProc variable

- 4.67.1.9. -