A connection block declaration can contain two special types of procedures: a PROLOG procedure, an EPILOG procedure, or both. These procedures are available in both ALGOL and NEWP.
PROLOG Procedures
For each connection in any connection library based on that connection block TYPE, the PROLOG procedure is executed the first time that connection is used in any way. The first use of a connection might occur in any of the following ways:
-
The connection might be specified in a LINKLIBRARY statement in the same program.
-
A statement elsewhere in the same program might access an object in the connection library. The object might be an imported object or a local object.
-
Another connection library might initiate a linkage to this one.
EPILOG Procedures
By contrast, an EPILOG procedure specifies the actions performed for each connection just before the connection block is deleted. The connection block is deleted when a program exits the procedure (or outer block) in which the connection block is declared. A separate instance of the EPILOG procedure is executed for each active connection of each connection library that is based on that connection block. In this context, a connection is considered active if it is currently linked or was previously linked and then delinked. (If a particular connection was declared, but never used, then the EPILOG procedure is not executed for that connection.)
Uses Outside Connection Blocks
PROLOG and EPILOG procedures can also be declared in structure blocks, where they behave similarly to the way they behave for connection blocks. Furthermore, EPILOG procedures can be declared in any procedure, and specify actions to be performed when the procedure is exited (refer to Using EPILOG and EXCEPTION Procedures in Using Events and Interlocks.
Order of Execution for EPILOG Procedures
A connection block EPILOG procedure is executed before any EPILOG procedure for the procedure that declares the connection block.
PROLOG and EPILOG Example
The following ALGOL example includes various combinations of PROLOG and EPILOG procedures:
100 PROCEDURE OUTERPROC; 110 BEGIN 115 EBCDIC ARRAY LIBF[0:23]; 120 130 EPILOG PROCEDURE OUTER_EPILOG; 140 BEGIN 150 % Procedure body statements 160 END; 170 180 TYPE CONNECTION BLOCK CL_TYPE; 190 BEGIN 200 INTEGER CONN_INT; 210 220 PROLOG PROCEDURE CL_PROLOG; 230 BEGIN 240 % Procedure body statements 250 END; 260 270 EPILOG PROCEDURE CL_EPILOG; 280 BEGIN 290 % Procedure body statements 300 END; 310 320 PROCEDURE CL_INIT(I); 330 INTEGER I; 340 BEGIN 350 CONN_INT:= I; 360 END; 370 380 PROCEDURE CL_EXP; 390 BEGIN 400 % Procedure body statements 410 END; 420 EXPORT CLEXP; 430 END; 440 450 CL_TYPE LIBRARY CL1 (LIBACCESS=BYFUNCTION, FUNCTIONNAME=“F1.”, 455 CONNECTIONS=3); 460 470 % End declarations, begin statements of procedure OUTERPROC 480 CL1[0].CL_INIT(5); 485 REPLACE LIBF BY “CLTEST1.”; 490 LINKLIBRARY (CL1[0], WAITFORFILE, INTERFACENAME = LIBF); 500 REPLACE LIBF BY “CLTEST2.”; 510 LINKLIBRARY (CL1[1], WAITFORFILE, INTERFACENAME = LIBF); 520 530 END OUTERPROC;
In the preceding example, the statement at line 480 is the first statement to use connection 0, and therefore causes the CL_PROLOG procedure to be executed for connection 0. The statement at line 510 causes the CL_PROLOG procedure to be executed for connection 1. The CL_PROLOG procedure is never executed for connection 2, because connection 2 is never actually used in this example.
When the OUTERPROC procedure is being exited, the system invokes separate instances of the CL_EPILOG procedure for connections 0 and 1. CL_EPILOG is not invoked for connection 2, because connection 2 is never used in this example. Then the system invokes the OUTER_EPILOG procedure. OUTER_EPILOG is executed only once, because OUTER_EPILOG is associated with the procedure OUTERPROC rather than with the connection block CL_TYPE.

