I have inherited the following code. I use VFP 7 SP1.

lcReportFile = SYS(2015)+".tmp"
REPORT FORM INVOICE TO FILE (lcReportFile) NOCONSOLE
nTotPages = _PAGENO
IF FILE(lcReportFile)
DELETE FILE (lcReportFile)
ENDIF

The above code is called in a loop from another procedure, it simply gets
the data for the current invoice that will be printed and determines the
total page count for the report. The invoices are printed once a day in a
batch normally a batch is 50-60 invoices. Maybe once a month or it may be
as long as 2 months the user receives error 1705 File access is denied on
the DELETE FILE (lcReportFile) line.

Is there anyway to force the file to be release from the REPORT FORM
command? I assume that is what is holding it open.

Thanks
Tom

Re: Report form to file does not release the file by Stefan

Stefan
Tue Apr 08 12:47:19 CDT 2008

If upgrading to Vfp9 with its brand new _pagetotal system
variable is not an option, does it help to "Set Printer To" right
before the Delete File attempt?
If not, does it help to run the "Set Printer To" line twice?
If not, do you get a proper pageCount result when you ommit
the "To File" clause
REPORT FORM test NOCONSOLE && does not print


hth
-Stefan


"Tom Libby" <tlibby@bigblue-usa.com> wrote in message
news:eQAUhkZmIHA.5208@TK2MSFTNGP04.phx.gbl...
>I have inherited the following code. I use VFP 7 SP1.
>
> lcReportFile = SYS(2015)+".tmp"
> REPORT FORM INVOICE TO FILE (lcReportFile) NOCONSOLE
> nTotPages = _PAGENO
> IF FILE(lcReportFile)
> DELETE FILE (lcReportFile)
> ENDIF
>
> The above code is called in a loop from another procedure, it simply gets the data for
> the current invoice that will be printed and determines the total page count for the
> report. The invoices are printed once a day in a batch normally a batch is 50-60
> invoices. Maybe once a month or it may be as long as 2 months the user receives error
> 1705 File access is denied on the DELETE FILE (lcReportFile) line.
>
> Is there anyway to force the file to be release from the REPORT FORM command? I assume
> that is what is holding it open.
>
> Thanks
> Tom
>



--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------


Re: Report form to file does not release the file by Tom

Tom
Tue Apr 08 13:27:08 CDT 2008

Your right REPORT FORM NOCONSOLE should do it. Not sure why he was sending
to a file. I know the _PAGENO is not always accurate, maybe he thought it
would be if sent to a file first. I will try that and see what happens.

Tom

"Stefan Wuebbe" <stefan.wuebbe@gmx.de> wrote in message
news:e6eJnCamIHA.5024@TK2MSFTNGP06.phx.gbl...
> If upgrading to Vfp9 with its brand new _pagetotal system
> variable is not an option, does it help to "Set Printer To" right
> before the Delete File attempt?
> If not, does it help to run the "Set Printer To" line twice?
> If not, do you get a proper pageCount result when you ommit
> the "To File" clause
> REPORT FORM test NOCONSOLE && does not print
>
>
> hth
> -Stefan
>


Re: Report form to file does not release the file by Paul

Paul
Tue Apr 08 14:20:44 CDT 2008


"Tom Libby" <tlibby@bigblue-usa.com> wrote in message
news:%233nZrYamIHA.748@TK2MSFTNGP04.phx.gbl...
> I know the _PAGENO is not always accurate, maybe he thought it would be if
> sent to a file first.

I seem to remember reading that if the report contains memo fields that
expand larger than one line, it's necessary to write to a file in order to
get the correct page count.




Re: Report form to file does not release the file by Tom

Tom
Tue Apr 08 14:28:01 CDT 2008

I recall something similar, although we do get inaccurate page counts even
writing to a file. For now I just set a flag before the delete and check for
it in my error routine and ignore the error and reset the flag after the
delete. I don't like it but it works.

Tom

"Paul Pedersen" <nospam@no.spam> wrote in message
news:OYIqh2amIHA.4712@TK2MSFTNGP04.phx.gbl...
>
> "Tom Libby" <tlibby@bigblue-usa.com> wrote in message
> news:%233nZrYamIHA.748@TK2MSFTNGP04.phx.gbl...
>> I know the _PAGENO is not always accurate, maybe he thought it would be
>> if sent to a file first.
>
> I seem to remember reading that if the report contains memo fields that
> expand larger than one line, it's necessary to write to a file in order to
> get the correct page count.
>
>
>



Re: Report form to file does not release the file by Paul

Paul
Tue Apr 08 14:50:54 CDT 2008


"Tom Libby" <tlibby@bigblue-usa.com> wrote in message
news:ufxdr6amIHA.1164@TK2MSFTNGP02.phx.gbl...
>I recall something similar, although we do get inaccurate page counts even
>writing to a file.

I believe that. I've even had the same problem with _PAGETOTAL in VFP9.

The most accurate way I've found is to send the report to a printer, then
count how many pages come out.



> For now I just set a flag before the delete and check for it in my error
> routine and ignore the error and reset the flag after the delete. I don't
> like it but it works.

I worked on an old 2.6 app years ago that had the habit of leaving lots of
temporary files on the disk - thousands of them, from many different
routines. Often they would leave the temp file because of a crash or other
early exit, before deleting the file. I solved the problem by giving all
temporary file names a recognizable prefix, then deleting all files with
that prefix on startup.




Re: Report form to file does not release the file by Rush

Rush
Tue Apr 08 15:31:28 CDT 2008

Tom Libby wrote:
> I have inherited the following code. I use VFP 7 SP1.
>
> lcReportFile = SYS(2015)+".tmp"
> REPORT FORM INVOICE TO FILE (lcReportFile) NOCONSOLE
> nTotPages = _PAGENO
> IF FILE(lcReportFile)
> DELETE FILE (lcReportFile)
> ENDIF
>
> The above code is called in a loop from another procedure, it simply gets
> the data for the current invoice that will be printed and determines the
> total page count for the report. The invoices are printed once a day in a
> batch normally a batch is 50-60 invoices. Maybe once a month or it may be
> as long as 2 months the user receives error 1705 File access is denied on
> the DELETE FILE (lcReportFile) line.
>
> Is there anyway to force the file to be release from the REPORT FORM
> command? I assume that is what is holding it open.
>
> Thanks
> To

Maybe:

IF FILE('C:\DeleteMe.tmp')
DELETE FILE C:\DeleteMe.tmp
ENDIF
REPORT FORM INVOICE TO FILE C:\DeleteMe.tmp NOCONSOLE
nTotPages = _PAGENO

- Rush