Share via


REPORT Command

Displays or prints a report under the control of a report definition file created with MODIFY REPORT or CREATE REPORT.

REPORT FORM FileName1 | ? [ENVIRONMENT] [Scope] [FOR lExpression1]
   [WHILE lExpression2] [HEADING cHeadingText] [NOCONSOLE]
   [NOOPTIMIZE] [PLAIN] [RANGE nStartPage [, nEndPage]]
   [TO PRINTER [PROMPT] [NODIALOG] | TO FILE FileName2 [ASCII]] [NAME ObjectName]
   [SUMMARY] [NORESET] [NOPAGEEJECT]
   [PREVIEW [[IN] WINDOW WindowName | IN SCREEN] [NOWAIT]]

Parameters

FileName1

Specifies the name of the report definition file to print. Starting with version 7 of Visual FoxPro, this parameter is also reported to the Print Spooler dialog box.

?

Displays the Open dialog box, from which you can choose a report file.

ENVIRONMENT

Included for backward compatibility with 2.x reports. To restore the data environment associated with a Visual FoxPro report, set the data environment AutoOpenTables property to true (.T.), which is the default. To make sure that the report environment is closed when the report has finished printing, set the data environment AutoCloseTables property to true (.T.), which is also the default.

For reports converted from earlier versions of FoxPro, including ENVIRONMENT opens and restores all the tables and relations in the Data Environment even if AutoOpenTables is set to false (.F.).

When you create or modify reports, you can save the current Visual FoxPro data environment with the report definition file. Saving the Visual FoxPro data environment places additional records in the report definition table for all open tables and index files, the index order, and any relationships between the tables.

Scope

Specifies a range of records to include in the report. The default scope for REPORT is ALL records. The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST. Only the records that fall within the range are included in the report. For more information on scope clauses, see Scope Clauses.

FOR lExpression1

Prints data only in those records for which lExpression1 evaluates to true (.T.). Including FOR makes it possible for you to filter out the records you don't want to print.

Rushmore Query Optimization optimizes REPORT FOR if lExpression1 is an optimizable expression. For best performance, use an optimizable expression in the FOR clause.

For more information, see SET OPTIMIZE and Using Rushmore Query Optimization to Speed Data Access.

WHILE lExpression2

Specifies a condition whereby data is printed for as long as the logical expression lExpression2 evaluates to true (.T.).

HEADING cHeadingText

Specifies text for an additional heading to be placed on each page of the report. The PLAIN clause takes precedence if you include both HEADING and PLAIN.

NOCONSOLE

Suppresses the echoing of a report to the main Visual FoxPro window or to a user-defined window when the report is being printed or sent to a file.

NOOPTIMIZE

To prevent Rushmore optimization of REPORT, include NOOPTIMIZE.

For more information, see SET OPTIMIZE and Using Rushmore Query Optimization to Speed Data Access.

PLAIN

Specifies that a page heading appears only at the beginning of the report.

RANGE nStartPage [, nEndPage]

Except in preview, specifies a range of pages to print. nStartPage specifies the first page printed; nEndPage specifies the last page printed. If nEndPage is omitted, the last page printed defaults to 32767.

TO PRINTER [PROMPT] [NODIALOG]

Sends a report to the printer.

The optional PROMPT clause displays a printer settings dialog box before printing starts. The printer settings that you can adjust depend on the currently installed printer driver.

The optional NODIALOG clause does not show the run-time print dialog box when a report is being sent to a printer.

TO FILE FileName2 [ASCII]

Specifies the text file to which you send a report. The current printer driver is used when the report is sent to the text file. The file created when you include TO FILE has the default extension .txt.

You can include the optional ASCII clause to create an ASCII text file from the report definition file. Without the ASCII clause, PostScript and other printer codes are written to the text file. Any graphics, lines, rectangles, or rounded rectangles in the report definition do not appear in the ASCII text file.

The number of columns and rows on each page in the ASCII text file is determined by the contents of the _ASCIICOLS and _ASCIIROWS system variables. The default values for _ASCIICOLS and _ASCIIROWS are 80 columns and 63 rows respectively. These values correspond to a standard portrait page.

NAME ObjectName

Specifies an object variable name for the data environment of a report. The data environment and the objects in the data environment have properties and methods, for example AddObject, that need to be set or called at run time. The object variable provides access to these properties and methods. If you don't specify a NAME, Visual FoxPro uses as a default the name of the report file that can be referenced in the code associated with the events.

SUMMARY

Suppresses detail line printing. Only totals and subtotals are printed.

NORESET

Specifies that the _PAGENO and _PAGETOTAL system variables are not reset. The page count for the current report begins at the current values of these two variables.

If you use the NORESET and RANGE keywords together, you must calculate beforehand which pages to print.

NOPAGEEJECT

Specifies that Visual FoxPro does not force a sheet eject at the end of a report and leaves the print job open. The next report printed is added to the open print job.

You can use NOPAGEEJECT to set up duplex printing, that is, printing on the reverse side of a previous report. You can also chain multiple reports and have page numbers continue from one report to the next, which is useful for tasks such as faxing reports.

Note   You must make sure that the last report run does not have a NOPAGEEJECT clause so the print job can be closed. NOPAGEEJECT is valid only in a program (.prg) and is disregarded when issued in the Command window.

Changing between page orientations, such as landscape to portrait, between reports is not supported.

The REPORT command still allows a NOEJECT keyword, which Visual FoxPro no longer supports but was used in older DOS versions of FoxPro and FoxBASE+.

PREVIEW [[IN] WINDOW WindowName | IN SCREEN]

Displays the report in page preview mode instead of sending the report to the printer. To print a report, you must issue REPORT with TO PRINTER.

System variables are ignored when you include PREVIEW.

You can include the optional WINDOW or IN WINDOW clause to specify a window in which the report is previewed. WindowName can be the name of a window created with DEFINE WINDOW. If you include the WINDOW clause, the preview assumes the characteristics (title, size, and so on) of the window you specify with WindowName. If you include the IN WINDOW clause, the report is previewed in the window you specify with WindowName.

You can include the optional IN SCREEN clause to specify that the report preview window is contained in the main Visual FoxPro window and cannot be moved outside it.

You can include the optional NOWAIT clause so that at run time Visual FoxPro does not wait for the page preview window to be closed before continuing program execution. Instead, Visual FoxPro continues program execution while the page preview window is open.

In a distributed application, be sure that the View menu is available. If the Print Preview toolbar is closed, it cannot be restored unless the View menu is available.

Remarks

The .frx file extension is the default extension for a report definition file. If the report definition file is not in the default directory or folder, you must include file name with the path.

Examples

Example 1

The following example shows how you can direct a batch report print job to a file.

REPORT FORM customer.frx TO FILE custorder.txt ASCII
REPORT FORM orders.frx TO TO FILE temp1.txt ASCII NORESET
STRTOFILE(FILETOSTR("temp1.txt"),"custorder.txt",1)

Example 2

The following example shows how to run a batch report print job with two reports. Visual FoxPro runs through the set of reports twice to obtain a total page count, which is stored in the _PAGETOTAL system variable for enabling Page X of Y numbering. Both reports contain also have _PAGETOTAL system variables.

Using the NOCONSOLE keyword without the TO PRINT keyword enables a quick run through the report without producing output in order to obtain page counts. NORESET specifies that page numbers continue printing with the next report. NOPAGEEJECT specifies that the first page of the second report continue printing on the reverse side of the last page of the first report. The lnPageTotal variable is later used to display the page number.

REPORT FORM myReport1.frx NOCONSOLE NOPAGEEJECT
REPORT FORM myReport2.frx NOCONSOLE NORESET
lnPageTotal = _PAGETOTAL
REPORT FORM myReport1.frx TO PRINTER NOPAGEEJECT
REPORT FORM myReport2.frx TO PRINTER NORESET

Example 3

The following example shows how you can view a preview before sending the report to a printer.

REPORT FORM myReport1.frx TO PRINTER PROMPT NODIALOG PREVIEW

See Also

_ASCIICOLS | _ASCIIROWS | CREATE REPORT | DataEnvironment Object | MODIFY REPORT | _PAGENO System Variable | _PAGETOTAL System Variable