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

**URL:** <https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491>\
**Category:** uncategorized\
**Created:** [September 22, 2021, 2:35pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491 "2021-09-22T14:35:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 22, 2021, 2:35pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/1 "2021-09-22T14:35:24Z")

</div>

I noticed when large 1000+ page Reports closed Preview there was an obvious pause of 10+ seconds before focus returned to the calling window. I traced this down to CLOSE(Report) which deletes the WMF files in the Temp folder. I added code before Close(Report) to delete files myself and the result was Close(Report) dropped from 10 to 1 second.

Attached project will let you time Report(close) on your system.

[ReportCloseSlowTest.zip](https://clarionhub.com/uploads/short-url/rTsj38JrpXcM1lrKhvZtM64dQlQ.zip) (9.1 KB)

Please enter your results in the poll and reply with screen captures of your tests. I’m curious how long it takes other to delete 1000 files? Note the Clarion version is in the window caption.

_Poll ([view on site](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/1))_

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 22, 2021, 2:48pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/2 "2021-09-22T14:48:57Z")

</div>

I did show this on the Wednesday [Clarion Live Open Webinar 9/22/21](https://www.youtube.com/watch?v=eYorFmVk_68&t=4m30s) at 4:30.

Test window looks like below. You can see on my system API delete is about 90x faster at 1000 pages.

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/c/c705d12aed7c850e470af800c7fbf2f2ade087d6.png)

Click _“1. RTL Normal”_ to test time to Close(Report) which shows in the Normal column.

Click _“2. API Delete”_ and it will run code like this that deletes all preview files before Close.

```
ReportCloseTempDeleteAPI(PreviewQ)
CLOSE(Report) 

ReportCloseTempDeleteAPI PROCEDURE(QUEUE RptPreviewQ)
QX LONG,AUTO 
cName CSTRING(261),AUTO   
  CODE
  LOOP QX=1 TO RECORDS(RptPreviewQ)
       GET(RptPreviewQ,QX)
       cName=CLIP(RptPreviewQ) 
       DeleteFile(cName)
  END
  RETURN
  !FYI DeleteFile(*CSTRING lpFileName ),BOOL,PROC,RAW,PASCAL,DLL(1),name('DeleteFileA')

```

_“No Preview”_ skips displaying the Preview Window so the testing process is faster.

_“Use RTL Remove”_ cause test #2 to use Remove() instead of API Delete. This proves that the RTL Remove() function is dreadfully slow. IMO that occured in C8 when it was changed to use SHFileOperation(). Below I highlighted one test where you can see Remove() takes 12.7 seconds versus 13.3 for Close(Report) so same speed and no where near as fast as API Delete.

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/3/31bc0d4035b1af3785e4d05d0979f6213a63ce09.png)

---

<div class="post-metadata">

**Author:** ![noyantis](https://clarionhub.com/user_avatar/clarionhub.com/noyantis/32/922_2.png) [@noyantis](https://clarionhub.com/u/noyantis)\
**Post date:** [September 22, 2021, 4:04pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/3 "2021-09-22T16:04:48Z")

</div>

The savings do speak for themselves…

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/4/4fd4aedf2d321bd79d25c8199c290aed18e47492.png)

Thanks Carl 🙂

---

<div class="post-metadata">

**Author:** ![Bostjan\_Laba](https://clarionhub.com/user_avatar/clarionhub.com/bostjan_laba/32/2498_2.png) [@Bostjan\_Laba](https://clarionhub.com/u/Bostjan_Laba)\
**Post date:** [September 22, 2021, 4:10pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/4 "2021-09-22T16:10:28Z")

</div>

![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/1/107e845d5073945f80343b5a273d9d5a9be014ad.png)

100x times faster (but without RTL Remove()).

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 22, 2021, 4:13pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/5 "2021-09-22T16:13:51Z")

</div>

> [@Bostjan\_Laba](#):
>
> (but without RTL Remove())

The “Use RTL Remove” box is to prove that the RTL Remove() is the slow _thing_. With that box checked you should see times similar to the #1 button Normal Close(Report).

Thanks for posting!

---

<div class="post-metadata">

**Author:** ![Bostjan\_Laba](https://clarionhub.com/user_avatar/clarionhub.com/bostjan_laba/32/2498_2.png) [@Bostjan\_Laba](https://clarionhub.com/u/Bostjan_Laba)\
**Post date:** [September 22, 2021, 4:25pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/6 "2021-09-22T16:25:41Z")

</div>

This is huge. I wish there was some global template that would use the faster way of deleting files instead of “classic” with rtl remove().

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 22, 2021, 5:11pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/7 "2021-09-22T17:11:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JaredDavis](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@JaredDavis](https://clarionhub.com/u/JaredDavis)\
**Post date:** [September 22, 2021, 6:41pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/8 "2021-09-22T18:41:43Z")

</div>

Hi,

Do you see the same time difference on remove vs api delete? Does the issue only show up on the close(report) usage?

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 22, 2021, 7:29pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/9 "2021-09-22T19:29:42Z")

</div>

> [@JaredDavis](#):
>
> Do you see the same time difference on remove vs api delete?

Yes REMOVE() is 100x slower than API DeleteFile. No its not just a Close(Report) issue. If you are deleting 100’s of files using REMOVE() will be slow.

You can test times for Remove() vs Delete file using the _View Temp_ button. The _PURGE_ button deletes the files on that window. Uncheck _API Delete_ to use REMOVE(). Once you press Purge the files are gone so you’ll need generate another Preview to compare checked vs unchecked:

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/8/8c903473bdbc95643a21e5d3275503b9da1da0d2.png)

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/2/21c90bafaea18c268bc5a85ce755c99dd50188fe.png)

---

<div class="post-metadata">

**Author:** ![Alla](https://clarionhub.com/user_avatar/clarionhub.com/alla/32/1892_2.png) [@Alla](https://clarionhub.com/u/Alla)\
**Post date:** [September 22, 2021, 8:25pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/10 "2021-09-22T20:25:13Z")

</div>

I COME FROM integrating the API function into my APPs  
The result is very good  
I also thought of copying my previewqueue in PDF format  
Is there a function to copy Image.wmf to PDF

Thank you very much for your initiative and your very precious help

Alla

---

<div class="post-metadata">

**Author:** ![JaredDavis](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@JaredDavis](https://clarionhub.com/u/JaredDavis)\
**Post date:** [September 22, 2021, 8:52pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/11 "2021-09-22T20:52:07Z")

</div>

Wow. Thanks.

I’ve had anti virus scanners block file deletes.  
create file → do something → delete file  
The antivirus was scanning it and blocked the delete.

Have you looked at the remove() operation api calls to see what it is doing?

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [September 23, 2021, 7:31am UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/12 "2021-09-23T07:31:03Z")

</div>

> [@Alla](#):
>
> Is there a function to copy Image.wmf to PDF

there are a number of tools available which will convert a queue of WMF files into a PDF document. The most obvious is the ReportToPDF functionality built into Clarion (EE?) itself - but there’s also wPDF and the now-not-available TrackerPDF. There are others as well.

Cheers  
Bruce

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [September 23, 2021, 2:14pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/13 "2021-09-23T14:14:42Z")

</div>

Thanks for the whole thread Carl - I’ve implemented a PremiereDeleteFilesInPrintPreviewQueue function in Premiere (build 3.36) . The template will automatically (by default, you can override at global or local level) make the call for you for ABC and Legacy reports. You can also call the function in hand-code if you like.

cheers  
Bruce

---

<div class="post-metadata">

**Author:** ![Bostjan\_Laba](https://clarionhub.com/user_avatar/clarionhub.com/bostjan_laba/32/2498_2.png) [@Bostjan\_Laba](https://clarionhub.com/u/Bostjan_Laba)\
**Post date:** [September 23, 2021, 2:51pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/14 "2021-09-23T14:51:01Z")

</div>

Now this I call FAST RESPONSE 🙂

Thanks Carl and Bruce 🙂

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 23, 2021, 8:29pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/15 "2021-09-23T20:29:17Z")

</div>

> [@JaredDavis](#):
>
> Have you looked at the remove() operation api calls to see what it is doing?

I stepped it in the Debugger and confirmed `REMOVE( String )` calls [SHFileOperation](https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shfileoperationa) . That function has a zillion features that make it slow. For a single file the function [DeleteFileA()](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-deletefile) should be used as it was prior to C8 adding a second parameter to REMOVE(, Options).

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/7/773de9b036b7cfbad6a7140c002c50a0aa1e5809.png)

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/4/459bf4016bf8645c298c6d74af99e74c3310284b.png)

---

<div class="post-metadata">

**Author:** ![JaredDavis](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@JaredDavis](https://clarionhub.com/u/JaredDavis)\
**Post date:** [September 23, 2021, 8:49pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/16 "2021-09-23T20:49:25Z")

</div>

Thanks. Do the deleted files end up in the Recycle bin with SHFileOperationA?

I can’t check right now.

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [September 23, 2021, 9:30pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/17 "2021-09-23T21:30:25Z")

</div>

That’s an option of the API, but I don’t believe Clarion is calling it that way.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [September 23, 2021, 9:38pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/18 "2021-09-23T21:38:27Z")

</div>

I checked and Close(Report) does not put files in Recycle bin.

The API has flag **FOF\_ALLOWUNDO** to recycle files but I don’t see that as an option flag for REMOVE():

```
REMOVE:FILESONLY EQUATE(01h) ! Remove normal files only if name has wildcards
REMOVE:RECURSIVE EQUATE(02h) ! Process nested directories recursively
REMOVE:PROGRESS EQUATE(04h) ! Show progress indicator
REMOVE:CONFIRM EQUATE(08h) ! Ask confirmations

```

The _enhanced_ REMOVE deletes files using wildcards and there is no option to turn it off.

---

<div class="post-metadata">

**Author:** ![JaredDavis](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@JaredDavis](https://clarionhub.com/u/JaredDavis)\
**Post date:** [September 23, 2021, 10:47pm UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/19 "2021-09-23T22:47:26Z")

</div>

Thanks. I was fishing to see if this was the source of another issue I have where the exe pauses for a couple of seconds. It freezes long enough for a watchdog to trigger. Then it gets ugly.

---

<div class="post-metadata">

**Author:** ![Oggy](https://clarionhub.com/user_avatar/clarionhub.com/oggy/32/397_2.png) [@Oggy](https://clarionhub.com/u/Oggy)\
**Post date:** [September 26, 2021, 8:35am UTC](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491/20 "2021-09-26T08:35:20Z")

</div>

Tested on the M2 “speedy” disk… Differences is massive…

 ![testing](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/2/2f855c1b42f8f529f36d55cc2249fc9c874867bd.png)

[Next page](https://clarionhub.com/t/test-if-close-report-is-slow-on-your-system-mine-100x-slower-than-c6/4491.md?page=2)
