>After doing quite a bit of testing, I don't think the problem is 1 or 2 passes, it is commands that generate errors.
>
>The code to print the report to file is pretty simple. The code that does the SPT queries and creates the group codes is lengthy and complex but it works fine and there are no issues unless I try to print to file. Here's that code:
>
>
>CREATE CURSOR PgCnt (caseno C(9),PageCnt INT(4))
>SELECT Groups
>REPORT FORM CaseSum0 TO FILE oApp.gcTempPath+'casesum.txt'
>
>
>In the application, the above Report command is not only slow, it causes the application to hang. (That's when I observed that someting was being sent to the printer immediately after casesum.txt was created yesterday. But I can't duplicate that now because of the error it causes.) I don't think the problem has anything to do with the report, the UDF or the data. I can duplicate the issue from the command window with the simplest of reports based on a single table. Here's what I found:
>
>
>SET REPORTBEHAVIOR 90
>
>REPORT FORM Test TO FILE myfile.txt
>REPORT FORM Test TO FILE myfile.txt ASCII
>REPORT FORM Test TO PRINTER
>REPORT FORM Test PREVIEW
>
>SET REPORTBEHAVIOR 80
>
>REPORT FORM Test TO FILE myfile.txt
>REPORT FORM Test TO FILE myfile.txt ASCII
>REPORT FORM Test TO PRINTER
>REPORT FORM Test PREVIEW
>
>Perhaps the above results were common knowledge but they were a surprise to me. Obviously I need to Set Reportbehavior 80 and use the ASCII clause when printing to file to prevent the application from hanging on the error when it tries to load the printer driver. This is occuring with SP1. It would be interesting to run the same code with SP2....
I can run this code in VFP 9 SP1 and VFP 9 SP2 and I don't get any error about loading a printer driver. Check to see if you have the printer environment stored in the report .. if so .. uncheck the Printer Environment option. Maybe that is interferring.
Also .. just as an FYI .. here's some info from the help file about the ASCII clause. MSFT changed the behavior in VFP 9.
When you omit the ASCII keyword or use Visual FoxPro's object-assisted output mode writes PostScript or other printer codes to the text file along with the content of your report. To create an ASCII text file from the report definition file, SET REPORTBEHAVIOR 80 and include the ASCII keyword.
Note
When you include the ASCII keyword, you can process a report on a computer that has no printer driver setups installed. Without the ASCII keyword, a REPORT FORM command issued on a computer that has no printer driver setups installed generates an error.