Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Check for wrong template-files

edited February 2003 in General
I want to check wether a report-template has the correct format.
Therefore I load the template into a report-component with following
code:

try
Report.Template.FileName:='C:\Temp\Reports\ppTmDlg.rtm';
Report.Template.LoadFromFile;
except
on E: EInvalidTemplateError do
showmessage(E.Message);
end;

When I load any text-file, the Exception raises, but then my app freezes
and I have to kill the process. Am I missing something or exists another
way.
I use Win2000, Delphi5, RB6.03


Guido

Comments

  • edited February 2003
    You shouldn't have to show a message in the exception. It should show it by
    default. Here is a simple form app event handler which works for the
    exception, and the main app continues running after the exception.

    uses
    ppTypes;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ppReport1.Template.Filename := 'C:\123.rtm';

    try
    ppReport1.Template.LoadFromFile;
    except
    on e: EInvalidTemplateError do
    Application.HandleException(Self);
    end;

    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    > You shouldn't have to show a message in the exception. It should show it by

    You are right, the app continues running, but I can't close the app. I still
    have to kill the process.


    Guido
  • edited February 2003
    The test application I am using works just fine after it catches the
    exception. What does you code do before and after the exception? Are you
    freeing any objects that you need to in a try/finally around the call to
    print this report? Please provide a simple test application that shows this
    problem and send it to support@digital-metaphors.com


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.