<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<blockquote type="cite">
<pre wrap=""><div class="moz-txt-sig">Message: 5
Date: Fri, 29 May 2009 23:45:17 -0400
From: Kenneth Brody <a class="moz-txt-link-rfc2396E"
href="mailto:kenbrody@spamcop.net"><kenbrody@spamcop.net></a>
Subject: Re: Issue with opening PDF file from FilePro
To: Fairlight <a class="moz-txt-link-rfc2396E"
href="mailto:fairlite@fairlite.com"><fairlite@fairlite.com></a>
Cc: <a class="moz-txt-link-abbreviated"
href="mailto:filepro-list@lists.celestial.com">filepro-list@lists.celestial.com</a>
Message-ID: <a class="moz-txt-link-rfc2396E"
href="mailto:4A20ABCD.7030109@spamcop.net"><4A20ABCD.7030109@spamcop.net></a>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Fairlight wrote:
[...]
</div></pre>
<blockquote type="cite">
<pre wrap=""><span class="moz-txt-citetags">> </span>1) Check for file's existance with exists(). If it's there, open it. If
<span class="moz-txt-citetags">> </span>you can open it read/write, then:
<span class="moz-txt-citetags">> </span>
<span class="moz-txt-citetags">> </span>2) Check the file's size with FILESIZE() on the opened handle.
<span class="moz-txt-citetags">> </span>
<span class="moz-txt-citetags">> </span>3) Institute a loop that sleeps for one second. Close the file, re-open
<span class="moz-txt-citetags">> </span>it, and check FILESIZE() each iteration. If you go a second with no new
<span class="moz-txt-citetags">> </span>data, you're -probably- safe to exit the loop and proceed onwards.
</pre>
</blockquote>
<pre wrap=""><!---->
There's no need to close/re-open the file. If the file size changes, then
FILESIZE() will see it. (Unless the O/S lies to filePro, which would mean
that bigger things would fail, like adding records to a file with no free
records.)
</pre>
<blockquote type="cite">
<pre wrap=""><span class="moz-txt-citetags">> </span>NOTE: I do -not- like this solution, as it IS still subject to a race
<span class="moz-txt-citetags">> </span>condition.
</pre>
</blockquote>
<pre wrap=""><!---->
I'm not sure if I would call it a "race condition". But, you are depending
on the file size changing between checks, which is in no way guaranteed.
</pre>
<blockquote type="cite">
<pre wrap=""><span class="moz-txt-citetags">> </span>And if you don't close/re-open the file between checks, be
<span class="moz-txt-citetags">> </span>it on your own head; I'm 50/50 as to whether or not FILESIZE() will pick
<span class="moz-txt-citetags">> </span>up on changes to the file's size once it's opened--depends how it's done
<span class="moz-txt-citetags">> </span>internally. This could be OS-dependant, or it may be absolute behaviour,
<span class="moz-txt-citetags">> </span>and only Ken can answer that.
</pre>
</blockquote>
<pre wrap=""><!---->
As I said, filePro will see the file size change unless the O/S lies to
filePro, which would cause other problems elsewhere.
</pre>
<blockquote type="cite">
<pre wrap=""><span class="moz-txt-citetags">> </span>That said, it -should- give reasonably consistent results if you check the
<span class="moz-txt-citetags">> </span>actual size over time.
</pre>
</blockquote>
</blockquote>
I tried this already and it can take a few seconds for the file to
start changing in size. It will open the file and the size will change
twice in the span of a second or two to about 2K as it is first
created. Then it will stay the same size for about another 5 or 6
seconds (sometimes more) until it jumps to the max file size (for this
one page report) of about 90K. So it would require way too much
checking to wait around for it to change.<br>
<br>
The solution that Bob suggested and that I mentioned earlier, where I
have PrintWizard create a second PDF file from within the same document
(in this case a single PrintWizard command line appended to the end of
the report that creates a blank PDF page with a unique filename) gives
an atomic solution. When that file exists then the first file must
also have been finished. Until then the first file is not ready.<br>
<br>
It's actually rather simple and not nearly as kludgy.<br>
<br>
<br>
</body>
</html>