Difference between revisions of "CEE4RAGE"
From MidrangeWiki
(Updated to add link to IBM documentation) |
m (link to programming) |
||
Line 1: | Line 1: | ||
− | |||
The CEE4RAGE API can be used to register a procedure that will be invoked with an [[activation group]] is destroyed. | The CEE4RAGE API can be used to register a procedure that will be invoked with an [[activation group]] is destroyed. | ||
Line 104: | Line 103: | ||
For more information on the API visit [http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/apis/CEE4RAGE.htm Register Activation Group Exit Procedure (CEE4RAGE) API] | For more information on the API visit [http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/apis/CEE4RAGE.htm Register Activation Group Exit Procedure (CEE4RAGE) API] | ||
+ | |||
+ | [[Category:API]][[Category:Programming]] |
Revision as of 14:22, 30 May 2008
The CEE4RAGE API can be used to register a procedure that will be invoked with an activation group is destroyed.
This can be used to force your own cleanup logic to be invoked when a particular program ends, regardless of how it ends.
The following example was posted to RPG400-L by Scott Klement ...
H NOMAIN D Initialized s 1N inz(*off) *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Initialization routine *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P InzSrvPgm B D InzSrvPgm PI D CEE4RAGE PR D procedure * procptr const D feedback 12A options(*omit) /free if (Initialized); return; endif; // .. open files here ... // .. other initializations ... CEE4RAGE(%paddr(EndSrvPgm): *OMIT); Initialized = *ON; return; /end-free P e *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * EndSrvPgm(): This is called automatically when the activation * group ends. (which is when the srvpgm is removed * from memory.) * * Note that this must be exported so that CEE4RAGE can call it. * * InzSrvPgm() registers this procedure with the CEE4RAGE() API *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P EndSrvPgm B export D EndSrvPgm PI D AgMark 10U 0 options(*nopass) D Reason 10U 0 options(*nopass) D Result 10U 0 options(*nopass) D UserRC 10U 0 options(*nopass) /free // ... terminate any helper processes // ... shut down any persistent APIs // ... close files. // ... deallocate memory. Initialized = *OFF; return; /end-free P E *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Every exported procedure (besides EndSrvPgm) starts by calling * the InzSrvPgm() subprocedure *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P SomeProc B export D SomeProc PI 10I 0 D SomeParm 123A const /free InzSrvPgm(); // ... perform function of subproc here ... return data; /end-free P E *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Every exported procedure (besides EndSrvPgm) starts by calling * the InzSrvPgm() subprocedure *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P AnotherProc B export D AnotherProc PI 10I 0 D AnotherParm 321A const /free InzSrvPgm(); // ... perform function of subproc here ... return data; /end-free P E
For more information on the API visit Register Activation Group Exit Procedure (CEE4RAGE) API