0
votes

I was wondering if anyone has had a similar experience. I am trying to trace the source of a problem but am coming up with nil. I have a project in Delphi 5 which has Report Builder reports on it. I needed an upgraded version of reportbuilder so I tried running the project in Delphi 7. When my project runs and I click a button to view a report, it views fine. However, if I use a paramstr to run the report (showmainform is set false) and show report procedure runs, I get get a stack overflow error.

The original code was :

 if lowercase(ParamStr(1)) = 'termsexceeded' then begin
    reportsdata.termsexceeded.close;
    reportsdata.termsexceeded.open;
    reports.ppTermsExceeded.print;
    reportsdata.termsexceeded.close;
    application.terminate;
  end; 

And it gave me the stack overflow error on the .print function.

The code that works in Delphi 7 is :

 if lowercase(ParamStr(1)) = 'termsexceeded' then begin
    reportsdata.termsexceeded.close;
    reportsdata.termsexceeded.open;
    reports.left := -10000;
    reports.show;
    reports.ppTermsExceeded.print;
    reportsdata.termsexceeded.close;
    application.terminate;
  end; 

Has anybody got a suggestion on how I could debug this to see if the problem lies with my Delphi 7 or with Reportbuilder ?

There are no events on the .show event of the reports form.

Any advice on how to get to the bottom of this would be appreciated.

Regards

1
On a sidenote, why do you need to set reports.left := -10000; ? - Kromster
The form that holds the report is a blank form so showing it looks untidy, so I set it out of user sight. - Oliver
Where does this code live? What invokes it? Is it in the main .dpr file? - David Heffernan
This code lives inside the main form of the application but the report component is on the reports form - Oliver

1 Answers

8
votes

When you get a stack overflow, use the debugger. It will interrupt your program when the OS throws the exception, and at that time, you can use the debugger's call stack window to see the path a function calls that lead there. You'll probably see a certain function or sequence of functions repeated many times.

When you've found the repeating pattern, check the code to see why it's repeating. Look for a condition is supposed to have changed, but doesn't.