DECLARE-PROCEDURE

Syntax

DECLARE-PROCEDURE [FOR-REPORTS=(report_name1[,report_namei]...)] [BEFORE-REPORT=procedure_name[(arg1[,argi]...)]] [AFTER-REPORT=procedure_name[(arg1[,argi]...)]] [BEFORE-PAGE=procedure_name[(arg1[,argi]...)]] [AFTER-PAGE=procedure_name[(arg1[,argi]...)]] END-DECLARE

Description

Declares procedures that are triggered when a specified event occurs.

The DECLARE-PROCEDURE command can be used to define SQR procedures that are to be invoked before or after a report is printed or before the beginning or end of each page.

Issue the DECLARE-PROCEDURE in the SETUP section. For multiple reports, you can use the command as often as required to declare procedures required by all the reports. If you issue multiple DECLARE-PROCEDURE commands, the last one takes precedence. In this way, you can use one command to declare common procedures for ALL reports and others to declare unique procedures for individual reports. The referenced procedures can accept arguments.

If no FOR-REPORTS are specified, ALL is assumed. Initially, the default for each of the four procedure types is NONE. If a procedure is defined in one DECLARE-PROCEDURE for a report, that procedure is used unless NONE is specified.

Use the USE-PROCEDURE command to change the procedures to be used at runtime. To disable a procedure, specify NONE in the USE-PROCEDURE statement.

Parameters

Parameter Description

FOR-REPORTS

Specifies one or more reports that use the given procedures. This argument is required only for a program with multiple reports. If you are writing a program that produces only a single report, you can ignore this argument.

BEFORE-REPORT

Specifies a procedure to be run when the first command that causes output to be generated (PRINT) is carried out. It can be used, for example, to create a report heading.

AFTER-REPORT

Specifies a procedure to be run just before the report file is closed at the end of the report. It can be used to print totals or other closing summary information. If no report was generated, the procedure does not run.

BEFORE-PAGE

Specifies a procedure to be run at the beginning of every page, just before the first output command for the page. It can be used, for example, to set up page totals.

AFTER-PAGE

Specifies a procedure to be run just before each page is written to the file. It can be used, for example, to display page totals.

You can optionally specify arguments to be passed to any of the procedures. Arguments can be any variable, column, or literal.

Example

The following example illustrates the DECLARE-PROCEDURE command:

declare-procedure              ! These procedures will

before-report=report_heading   ! be used by all reports

after-report=report_footing
end-declare
declare-procedure             ! These procedures will

for-reports=(customer)        ! be used by the customer

before-page=page_setup        ! report

after-page=page_totals
end-declare

See USE-PROCEDURE