ECLOSE_METHOD
Perform application close processing
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
subroutine ECLOSE_METHOD a_noclr ,n a_cancel ,n a_type ,n
Arguments
a_noclr
Returned with any no_clear flag passed to U_FINISH. (n)
a_cancel
(optional) The cancel shutdown flag which is passed to U_FINISH. (n)
a_type
The flag defining the type of shutdown in progress: (n)
0 = U_FINISH was called directly.
1 = The user is closing the application.
2 = An interrupt (^C) was received.
Discussion
ECLOSE_METHOD is a subroutine that you write and name. The name of your subroutine is registered with UI Toolkit using the E_METHOD subroutine. UI Toolkit calls your ECLOSE_METHOD subroutine to allow customized shutdown processing for your application.
- On Windows, ECLOSE_METHOD is called when U_FINISH is called and when the user closes the application using the System menu, close box, or Close menu entry. (This is applicable only if you have previously called U_START and interrupt is enabled.)
- On Unix and OpenVMS, ECLOSE_METHOD is invoked only when U_FINISH is called (so a_type is always 0 on these platforms).
An ECLOSE_METHOD method should return after processing and should include TRY and CATCH blocks to catch potential exceptions. It should not include a STOP statement or cause an untrapped error.
If a_cancel is passed, this method can set it to true to cancel application shutdown if you passed the cancel argument to U_FINISH.
See also
- E_METHOD for registering your ECLOSE_METHOD with the environment
- E_STATE routine for more information on enabling interrupt characters
- U_FINISH routine for more information about managing your application’s shutdown procedures
- Overloading UI Toolkit routines for more information on creating this subroutine
- Appendix D: Methods
The following method would have to be registered in the transaction routine’s environment.
subroutine trx_close ; ; Description: Close method for transaction entry ; ; Arguments: ; a_noclr ,n ;"No clear" option for U_FINISH a_cancel ,n ;(Optional) cancel shutdown flag a_type ,n ;Type of shutdown: ; 1 = Close ; 2 = Interrupt .include "trxgbls.def" ;Global fields (g_changes, etc.) ; .align record style ,i4 ;Message box style proc if (g_changes) ;Are there unsaved changes ; to the transactions? begin if (^passed(a_cancel)) then ;Can we cancel ; shutdown? style = D_MYESNOCANCEL ;Yes, include ; cancel button else style = D_MYESNO ;No, only allow ; yes/no style = style + D_MICONEXCLAM ;Put an exclamation ; icon on using %u_msgbox("Save changes to transactions?", style) select (D_MIDYES), call save ;Save the transactions (D_MIDNO), nop ;No action required (D_MIDCANCEL),a_cancel = TRUE ;Cancel shutdown endusing end xreturn save, ;Insert code here to save all changes to ; transaction file return endsubroutine
The following code shows how you would use E_METHOD to register this method:
proc xcall e_enter xcall e_method(D_METH_APPCLOSE, "trx_close") . . . xcall e_exit xreturn .end