The following restrictions apply to epilog procedures:
-
No parameters are allowed.
-
An invalid GO TO statement cannot be used to exit from an epilog procedure to an outer block. A run-time error occurs if an attempt is made to perform an invalid GO TO statement.
-
An epilog procedure cannot return a value.
-
An epilog procedure cannot contain an EPILOG PROCEDURE declaration. A block or procedure cannot have more than one EPILOG PROCEDURE declaration (or an EPILOG PROCEDURE declaration and an EXCEPTION PROCEDURE declaration).
-
An epilog procedure cannot be declared as a formal parameter.
-
Certain restrictions are placed on programs that contain EPILOG PROCEDURE declarations. Epilog procedures cannot be declared as EXTERNAL. Only replacement binding can be used. A block or procedure with an EPILOG PROCEDURE declaration in its outer block cannot be used as the host code file when running BINDER. No procedure in a block that has an EPILOG PROCEDURE can be replaced by the BINDER.
-
If a program that contains one or more EPILOG PROCEDURE declarations fails due to a fatal stack overflow, the epilog procedures will not be executed.
-
If the outer block (or procedure) of a program contains an EPILOG PROCEDURE declaration and the statistics option is TRUE, the epilog procedure is executed at block exit time before the statistics wrap-up code.
-
If certain Data Management System (DMS) functions such as DATABASE OPEN or DATABASE CLOSE are called, it might not be possible to return to the epilog procedure if the executing task is discontinued.
-
Structure or connection block epilog procedures can declare and invoke additional structure types and structure blocks. However, if a new structure or connection block instance is created as a result of calling the epilog procedure of another structure or connection block in the block, its own epilog procedure is not invoked if its declaration occurs after the point in the block that the declaration occurs for the structure or connection block instance whose epilog procedure is running.
In the following example, the only structure block that has been created (allocated) when the exit of the block occurs is SBA[1], which is at a lower lex offset than SBG.
BEGIN
TYPE STRUCTURE BLOCK SBT; FORWARD;
SBT ARRAY SBGA [0:9];
SBT SBG;
TYPE STRUCTURE BLOCK SBT;
BEGIN
EPILOG PROCEDURE EPI;
BEGIN
SBG.P;
SBGA[9].P;
END; %EPI
PROCEDURE P;
BEGIN
END; %P
END; % SBT
SBGA[1].P;
END; %BLOCKIn this example, the first call to EPI of SBT occurs for SBGA[1] which is after the point at which epilogs would have been called for SBG and SBGA[9], yet the epilog call for SBGA[1] causes both of those to become active.
The epilogs of elements of structure block arrays are called in reverse index order for the structure block array upon exit of the block that declared the structure block array. Only epilogs of structure block array elements that have been allocated are invoked.
Every procedure with critical locking code or critical block exit code of some type should have an EPILOG PROCEDURE declaration in it. All critical block exit code must be contained in the epilog procedure. Whenever the procedure is exited (either normally or abnormally) the epilog procedure is executed.
The order for cleanup of blocks containing structure block variables or structure block arrays or connection libraries is the following:
-
If an epilog procedure for this block exists, it is run first.
-
Epilog procedures for existing structure or connection blocks emanating from this block run, and any libraries linked to those structure or connection blocks are delinked.
-
Libraries linked to the block are delinked. Libraries delinked by BLOCKEXIT cannot be relinked.
-
Critical block action is taken for process family members.
-
The structure or connection block instances are cleaned up and destroyed.

