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

validating report template file format errors

edited June 2002 in General
hi,

we are trying to protect a TppReport.LoadFromStream routine with a try
except so we can take our own actions when the we have encounter bad
template data. We have run into a problem where if we give the report
template a bad file and then show a message dialog, the code after the
message dialog does not fire and the program just hangs. Below is a sample
routine the illustrates the problem. Does anyone know why this code doesn't
work?

thanks!

rob


procedure TForm1.Button2Click(Sender: TObject);
var
aStream: TMemoryStream;
begin
aStream := TMemoryStream.Create;
try
// if the file exists load it into the template
if fileExists(theFile) then begin
astream.LoadFromFile(theFile);
end;
astream.position := 0;
// if the file has something in it, try to load it into the template
if aStream.size>0 then begin
try
ppReport1.Template.LoadFromStream(Astream);
except
MessageDlg('Template load error', mtError, [mbOK], 0);
ppReport1.Template.New; // <---- doesn't get called, program hangs
when bad template file
end;
end;
ppDesigner1.Show;
finally
astream.free;
end;
end;

Comments

This discussion has been closed.