// MDI Save Event Handler

  Requires(20170103);
  PushTagsandRegisters;

  Relax; // No default action is taken here...
  JMP(!'cleanup');

// ===========================================================================

  // Inside this event handler all variables and macros refer to the
  // document that is about to be saved!

  // Here is where you can update any Time Stamps, etc...
  // If format is Mode-Dependent use the IfisMode() function!

  IfStr('%f',!'',!'=',!"JMP(!'new_Doc');");
  IfStr('%f','%!a',!'=',!"JMP(!'act_Doc');");
  JMP(!'non_act_Doc');

:Update_HTML_DateStamp:: =====================================================
  IfisMode(!'HTM','%!m',!'Relax;',!'Return;');
  SaveFind;
  SetSearchCaseSensitive(1);
  SetSearchRelaxed(0);
  SetSearchWholeWords(0);
  SetSearchInline(1);
  SetSearchEntire(0);
  SetSearchForward(0);
  SetSearchCyclic(0);
  SetSearchCurrentDoc;
  SetRegEx(1);
  SetFindStr(!'<  Last change: ');
  SearchReset;
  SetTracking(0);
  Mark(9);
  GoToEndOfFile;
  IfFound(!'Relax;',!"JMP(!'Update_HTML_DateStamp_Done');");
  SetSearchForward(1);
  SetReplacePrompt(0);
  SetReplaceNotify(0);
  SetFindStr(!'  Last change: *~~>');
  GetDate(9,!'dddd, mmmm d, yyyy  hh:nn');
  SetReplaceStr('  Last change: %!9');
  SearchReset;
  Replace;
:Update_HTML_DateStamp_Done:: ================================================
  Goto(9,1);
  SetTracking(1);
  RestoreFind;
Return;

:act_Doc:: ===================================================================

  Relax;
  Call(!'Update_HTML_DateStamp');
  JMP(!'cleanup');

:non_act_Doc:: ===============================================================

  Relax;
  Call(!'Update_HTML_DateStamp');
  JMP(!'cleanup');

:new_Doc:: ===================================================================

  Relax;
  JMP(!'cleanup');

:cleanup:: ===================================================================

  PopTagsandRegisters;

End;
