ESPL: Event Redirection

Q:  How can ESPL be notified when the Ensign program is closing so that information can be saved before the program closes?

A:  Redirect the OnCloseQuery event for the main Ensign form to an ESPL procedure which performs the clean-up tasks such as saving information.  The main Ensign form is referenced with the component named   frmMain.   This example will print a message in the Output window when Ensign closes.

uses
  Forms;
procedure ShutDown;
begin
  writeln('Exiting');
end;
begin
  if ESPL = 3 then
    frmMain.OnCloseQuery := 'ShutDown';
end;
Cick ESPL button 3 to establish the redirection of the OnCloseQuery event.  Then when Ensign exits, the OnCloseQuery event fires and executes the ESPL ShutDown procedure which displays ‘Exiting’ in the Output window.  Ensign continues its exit process and closes down.