JavaScript Editor js editor     Web development 

Main Page

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


Return Value

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

Value Description


There is no active report.


Report is in Preview Mode


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


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.

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.


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

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

See Also

JavaScript Editor js editor     Web development