Partilhar via


SYS(2040) - Detect Report Status

Detects whether a report is being printed or is in preview mode.

SYS(2040)

Return Value

Character data type. Returns the current status of the report as follows.

Value Description

0

There is no active report.

1

Report is in Preview Mode

2

Report is being sent as output (such as a printer or file).

Remarks

The SYS(2040) function is useful when you want to control content in a report depending on how it is being viewed. For example, you can print a message such as Confidential or Classified but not display it when the report is in Preview Mode.

Note

The value returned by SYS(2040) does not provide information about whether there is an active preview window displayed. It provides information about whether the Visual FoxPro Report System is in process of generating output only, not with what happens to those results after they were generated. For example, SYS(2040) returns "0" after you use the command REPORT FORM OBJECT TYPE 1 (invoking an object-assisted report preview), even though the preview window is still on-screen, and it returns "0" after it sends output to a printer and closes the print queue, even though some of that output is not yet completely printed. By contrast, if your error handler is triggered, you can use SYS(2040) to determine whether the error was triggered by code occurring during a report run. Your error handler can use the value to determine whether it should do any report-specific cleanup before it exits your application.

Example

The following example displays how SYS(2040) can be used to suppress the _PAGETOTAL system variable when the report is in Preview Mode.

"Page: " + TRANS(_PAGENO) + ;
IIF( SYS(2040) = "1", "", " of " + TRANS(_PAGETOTAL))

See Also

Reference

SYS( ) Functions Overview
REPORT FORM Command

Concepts

Understanding Visual FoxPro Object-Assisted Reporting