Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spinning circle icon during REPORT PREVIEW

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
An application has a facility for showing a report preview on the screen. The code to do this is broadly :

Code:
   *  Create and populate the cursor containing the data for the report
*  set lRepname to the name of the frx.frt files containing the report definition
   .  .  .  .
   oRepForm = CREATEOBJECT("Form")
   WITH oRepForm
      .WindowState = 0   && This puts the form into windowed state.
      *  Then set height and width according to space available
      ENDWITH
   REPORT FORM &lRepname PREVIEW WINDOW (oRepForm.Name)

When this code is run, it sometimes shows the spinning circle icon for a fraction of a second or for a few seconds while the report is showing on the screen. Only then can the user scroll up and down the preview, scroll to the next page &c. And occasionally the program will stall so that the user has to escape with Ctrl-Alt-Del.

If the report preview is run twice consecutively, it often happens that the first time it will stall briefly, but on a subsequent run it will run through smoothly

This effect can happen both in the development environment and also on a user's site where he is running the .exe file which has been built and distributed.

Have any other users experienced this effect?
 
Andrew,

It might be useful to narrow the problem down. In particular:

1. What happens if you run the report in the native preview window, rather than your own form? Do you see the same behaviour?

2. What happens if you run a different report in your form?

3. Where does the report obtain its data? Does the report itself open the necessary tables? Or is there code somewhere to create a cursor for the report?

Item 3 above is probably the most useful to investigate, especially given that the problem does not arise on second and subsequent runs of the report. That might suggest that the data is being cached behind the scenes.

Just something to think about.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I think Mike is on the right track(s).

Notice that Createobject("form") creates a form object with name "Form1", which is not very unique for the later REPORT FORM ... WINDOW (oRepForm.Name),
but I it can't be the form that takes that long.

To follow Mikes advice and check what happens without your own preview windows, instead of all your code just do:

Code:
REPORT FORM &lRepname PREVIEW

There's not much to do if, as Mike suspects it's data retrieval taking the time other than accelerating the data retrieval.


Chriss
 
Thanks Mike, for your prompt reply. The behaviour seems pretty consistent.

1. What happens if you run the report in the native preview window, rather than your own form? Do you see the same behaviour?

I can change the report preview to
REPORT FORM &lRepname PREVIEW IN SCREEN

But we get the same effect. The preview does indeed show in a default window, but it still sometimes hangs with the rotating circle on the first invocation. Less likely on subsequent invocations

2. What happens if you run a different report in your form?

The result is the same. If I run an aged debtors report, from a different part of the system. The report still sometimes hangs

3. Where does the report obtain its data? Does the report itself open the necessary tables? Or is there code somewhere to create a cursor for the report?

There is indeed code to create a cursor, and in this case (a bank listing) all the fields for each line of the report have been placed into a single record in the cursor. There are a few other fields which come from global variables within the application (like the user’s name). But these have all been determined before the REPORT FORM command is executed. The only other fields on the report are a few ‘Totalled’ fields.

The place where the report hangs is on the single instruction in my program which says REPORT FORM. This can be verified by including a breakpoint (SET STEP ON) before and after the REPORT FORM command. You can see the report in all its glory pretty promptly, but then there is occasionally a period of a few seconds with the spinning circle before the user can scroll up and down.

Thanks again.
 
Andrew,

this is with set reportbehaviour set to 90?

you might look at where the .app files are located; reportoutput.app, reportpreview.app and system.app.

Make sure they are in a local path and perhaps set default to that folder. I had trouble recently with system.app functions taking an age because VFP was searching a large or slow default folder.

hth

n


 
Hi,

is the page shown completely when the spinner appears ?
Do you have something like trans(_pageno)+"/"+trans(_pagetotal) in the report (so it must run twice) ?

Is there code in on entry / on exit ?
Is there a grouping used without a matching index on the cursor (so report engine has to create it) ?

Can you try with foxypreviewer for preview ?

Regards
tom
 
Andrew,

Tom mentioned _pagetotal. This can indeed slow down a large report preview quite considerably, as it requires the report engine to do two passes of the report. In fact, I doubt if it is the cause of the problem in this case, given that your input cursor is quite small (if I have understood it right).

Still, it is worth keeping this in mind. If you have a particularly large report, and if the report is running slowly, and if you want to show pages numbers in the form "Page n of m", then you should use this expression to display the page number:

Code:
"Page: " + TRANS(_PAGENO) + ;
IIF( SYS(2040) = "1", "", " of " + TRANS(_PAGETOTAL))

That tells the report to display the total number of pages when the report is being printed, but not in preview (when any delay is likely to be more noticeble).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
As far as I see you have all data prepared and the report is just about one reocord? Then I understand you don't expect something to take that long.

What if you don't do any IN WINDOWS or IN SCREEN clause?

Just
Code:
REPORT FORM &lRepname PREVIEW

Chriss
 
Hello Nigel

Thank you for your reply. SET(“REPORTBEHAVIOR”) actually returns 80. It is back in the mists of time, but I see a comment in my code :
Code:
   *  This is included to get round a bug in Right-Click | Report preview
*  SET REPORTBEHAVIOR 80

I suspect that this may have been because of a similar problem. The whole application runs with this 80 setting.

The several report*.app files are in a subfolder of the home directory where the application is running. This is all on a local drive C:

Very grateful for your guidance

and Tomk3

Thank you for your input. The page is indeed shown completely when the spinner appears. And this report ( a bank listing) does not mention _pagetotal.

It is odd. The program can produced a report of thirty or so lines from a 30-record cursor, with a line of totals at the foot of the page, on a single page;, and it sometimes then shows the spinning circle.

I quite understand that - if the report is a long report – the spinner could appear while REPORT is gathering the data. But where VFP shows the report but then shows the spinner, it is odd.

I had better do some more testing and see if I can get the error to appear consistently!

Thank you all for your help.
 
Another idea is maybe it has to do with the printer driver. That's not only involved when printing, finally, but also at least has to contribute printable area and page margin informations at least. It would explain why this is a first time issue, only, too.



Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top