>>DEFINE CLASS vfpreport AS custom OLEPUBLIC >> Name = "vfpreport" >> *-- To run a VFP report and send the output to a text file >> PROCEDURE reportrun >> * Purpose: To run a VFP report and send the output to a PDF file >> * >> * Parameters: >> * tcReportFrx: VFP report >> * tcPdfPrinter: PDF printer name >> * >> * Return: PDF file >> >> LPARAMETERS tcReportFrx, tcPdfPrinter >> LOCAL lcOldCentury, lcOldDefault, lcOldPrinter, lcReportPdf, lcReportPs >> >> * Initial settings >> >> lcOldCentury = SET("Century") && Save Century setting >> lcOldDefault = FULLPATH("") && Save default directory >> lcOldPrinter = SET("Printer", 3) && Save current printer >> SET CENTURY ON && Display four-digit year >> SET DEFAULT TO (SYS(2023)) && Go to temporary directory >> SET PRINTER TO NAME (tcPdfPrinter) && Set PDF printer >> lcReportPdf = SUBSTR(SYS(2015), 3, 10) && File name for report output >> lcReportPs = lcReportPdf + ".ps" && Text file for report output >> lcReportPdf = FULLPATH(lcReportPdf + ".pdf") && PDF file for report output >> >> * Run report >> >> IF FILE(lcReportPs) && If text file exists... >> DELETE FILE (lcReportPs) && Delete text file >> ENDIF >> >> IF FILE(tcReportFrx) && If report does exist... >> REPORT FORM (tcReportFrx) TO FILE (lcReportPs) NOCONSOLE && Run report and send output to text file >> IF FILE(lcReportPs) && If text file exists... >> DELETE FILE (lcReportPs) && Delete text file >> ENDIF >> ENDIF >> >> * Restore settings >> >> SET CENTURY OFF && Restore Century setting >> SET DEFAULT TO (lcOldDefault) && Restore default directory >> SET PRINTER TO NAME (lcOldPrinter) && Restore current printer >> >> RETURN lcReportPdf >> ENDPROC >>ENDDEFINE >