validating report template file format errors
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;
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;
This discussion has been closed.
Comments
you have little blue dots left of your editor? I can send you my test
project if you would like.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
thanks jim.
Rob
--
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com