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

Use of ArchiveReader

edited November 2010 in General
Hi all,

Still using Delphi 7 and RB 7.04 (or whatever that last D7 version
is). I have a sub-form that prints a report and then prints the report
to a daily safed archive file with this code:
// 10/31/2010 8:24:28 AM ED: For Georgia
allowPrintToArchive := true;
deviceType := 'archiveFile';
archiveFileName := 'C:\data\ClosingLog.raf';
//print;
try begin
if fileExists(archiveFileName)
then DeleteFile(ArchiveFileName);
print;
end;
finally
end;
end;

On the main form is an ArchiveReader that is called using this code:
const
fname = 'c:\data\ClosingLog.raf';
begin
archiveReader.archivefilename := fname;
if fileExists(fname)
then archiveReader.print // 10/31/2010 8:24:09 AM ED: For Georgia
else ShowDlgOops('There is no saved Closing Log to review.');
archiveReader.archivefilename := '';
archiveReader.Reset;
end;

Which works. Previously, I just had the filename be a property of the
ArchiveReader. And I didn't reset it, doing this:
if fileExists(fname)
then archiveReader.print // 10/31/2010 8:24:09 AM ED: For Georgia
else ShowDlgOops('There is no saved Closing Log to review.');

The result I got was everything worked hunky dory UNLESS the
ArchiveReader function was called. In which case, I got a Unable to
Open File error when printing the closing log at the end of the day to
the archive filename. Obviously, the ArchiveReader was holding onto to
the file and not releasing it when the function finished.

Question: Is RESET the right way to handle this issue? Would I be
better off CREATING the archiveReader on the fly and then releasing it
(and hopefully it's hold on the file)?

Thanks in advance, GM

Comments

This discussion has been closed.