Test if Close(Report) is SLOW on your System? – Mine 100x slower than C6

I use Legacy so it was easy for me to modify the shipping GReport.TPW.

#EMBED(%BeforeClosingReport,'Before Closing Report')

Inserted call to ReportPreviewPurge(PrintPreviewQueue) only #IF(%EnablePrintPreview) 

CLOSE(%Report)
#EMBED(%AfterClosingReport,'After Closing Report')
#IF(%EnablePrintPreview)
FREE(PrintPreviewQueue)
#ENDIF

I wanted my delete code on the line right before Close(Report) so I modified the shipping TPW. I did not want to risk using an #AT(%BeforeClosingReport),LAST in case there was other template code there trying to grab the WMFs. The #AT would probably be fine and allow a single Global Extension to apply to all reports.


In ABC the Close(Report) is buried in ReportManager.TakeCloseEvent(). It looks easy to modify ABReport.CLW and very nice it applies to ALL ABC reports. You just have to do it each new release, but it is worth it for the speed improvement.

TakeCloseEvent() was the wrong place, thank you Bruce, because it calls.AskPreview() which always does Free( PreviewQ ). So the files must be deleted in ReportManager.AskPreview before the Free(Q). I do that calling my new method DeleteTempFilesFast_Carl()

! ---------------------- ABReport.CLW ------------------

ReportManager.AskPreview PROCEDURE()
RetValue   BYTE,AUTO
  CODE
  RetValue = SELF.EndReport()
  IF SELF.Report &= NULL OR SELF.Response <> RequestCompleted OR SELF.OpenFailed

    !Report cancelled by user so there are files to delete if SELF.Response  <> RequestCompleted 
    SELF.DeleteTempFilesFast_Carl()  !<-- ADD -- Fast Close new code

    RETURN
  END
  IF RetValue = Level:Benign
    IF SELF.SkipPreview OR SELF.Preview &= NULL OR SELF.Preview.Display (SELF.Zoom)
      SELF.PrintReport()
    ELSE
      SELF.CancelPrintReport()
    END
  END

  SELF.DeleteTempFilesFast_Carl()  !<-- ADD -- Fast Close new code
  IF NOT SELF.Preview &= NULL
    FREE (SELF.Preview.ImageQueue)
  ELSE
    FREE (SELF.PreviewQueue)
  END
  RETURN

You need to add this new method to ABReport .INC and .CLW that deletes the files:

ReportManager.DeleteTempFilesFast_Carl PROCEDURE()!,VIRTUAL !<-- ADD -- new method
PreviewQ &PreviewQueue
Idx   LONG,AUTO
cName CSTRING(261),AUTO   
  CODE
  IF SELF.Report &= NULL OR SELF.OpenFailed THEN RETURN.  !Never got started 
  IF NOT SELF.Preview &= NULL
    PreviewQ &= SELF.Preview.ImageQueue
  ELSE
    PreviewQ &= SELF.PreviewQueue
  END
  IF PreviewQ &= NULL THEN RETURN. 
  LOOP Idx=1 TO RECORDS(PreviewQ)
     GET(PreviewQ,Idx)
     cName=CLIP(PreviewQ) 
     DeleteFile_Carl(cName)
  END
  RETURN
  
!TODO: Report.CLW Add to MODULE('WinApi') --> DeleteFile_Carl(*CSTRING lpFileName ),BOOL,PROC,RAW,PASCAL,DLL(1),NAME('DeleteFileA')  
!TODO: Report.INC Add to ReportManager    --> DeleteTempFilesFast_Carl PROCEDURE(),VIRTUAL
!Simpler: instead add DeleteTempFilesFast_Carl(ReportManager SELF) to the CLW Map so Private

This code compiles but has had minimal testing. I have been running similar code in Legacy for a year on many systems with no issues.

3 Likes