AT TOP OF PAGE

Structured Mode Syntax

[ATTOP [OFPAGE  [(rep)]
   statement ../graphics/dot3.gif
END-TOPPAGE

Reporting Mode Syntax

[ATTOP [OFPAGE [(rep)]

statement

DO statement ../graphics/dot3.gif DOEND

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Related Statements: AT END OF PAGE | CLOSE PRINTER | DEFINE PRINTER | DISPLAY | EJECT | FORMAT | NEWPAGE | PRINT | SKIP | SUSPEND IDENTICAL SUPPRESS | WRITE | WRITE TITLE | WRITE TRAILER

Belongs to Function Group: Creation of Output Reports


Function

The statement AT TOP OF PAGE is used to specify processing which is to be performed when a new page is started.

See also the following sections in the Programming Guide:

Processing

A new page is started when the internal line counter exceeds the page size set with the session parameter PS (page size for Natural reports), or when a NEWPAGE statement is executed. Either of these events cause a top-of-page condition to be true. An EJECT statement causes a new page to be started but does not cause a top-of-page condition.

An AT TOP OF PAGE statement block is only executed when the object which contains the statement is active at the time when the top-of-page condition occurs.

Any output created as a result of AT TOP OF PAGE processing will appear following the title line with an intervening blank line.

This statement is non-procedural, that is, its execution depends on an event, not on where in a program it is located.

Restriction

An AT TOP OF PAGE statement must not be placed within an inline subroutine.

Syntax Description

Syntax Element Description
(rep)
Report Specification:
The notation (rep) may be used to specify the identification of the report for which the AT TOP OF PAGE statement is applicable.

A value in the range 0 - 31 or a logical name which has been assigned using the DEFINE PRINTER statement may be specified.

If (rep) is not specified, the AT TOP OF PAGE statement applies to the first report (Report 0).

For information on how to control the format of an output report created with Natural, see Controlling Data Output in the Programming Guide.

statement ...
Statement(s) to be Executed at Start of Data Condition:

In structured mode, you must supply one or several suitable statements, depending on the situation. For an example of a statement, see Example below.

END-TOPPAGE
End of AT TOP OF PAGE Statement:

In structured mode, the Natural reserved word END-TOPPAGE must be used to end the AT TOP OF PAGE statement.

In reporting mode, use the DO ... DOEND statements to supply one or several suitable statements, depending on the situation, and to end the AT TOP OF PAGE statement. If you specify only a single statement, you can omit the DO ... DOEND statements. With respect to good coding practice, this is not recommended.

statement ...
DO statement ... DOEND

Example

** Example 'ATPEX1S': AT TOP OF PAGE (structured mode)                  
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPLOY-VIEW VIEW OF EMPLOYEES                                         
  2 NAME                                                                
  2 FIRST-NAME                                                          
  2 CITY                                                                
  2 DEPT                                                                
END-DEFINE                                                              
*                                                                       
FORMAT PS=15                                                            
LIMIT 15                                                                
READ EMPLOY-VIEW BY NAME STARTING FROM 'L'                              
  DISPLAY 2X NAME 4X FIRST-NAME CITY DEPT                               
  WRITE TITLE UNDERLINED 'EMPLOYEE REPORT'                              
  WRITE TRAILER '-' (78)                                                
  /*                                                                    
 AT TOP OF PAGE                                                        
    WRITE 'BEGINNING NAME:' NAME                                        
  END-TOPPAGE
  /*                            
  AT END OF PAGE                
    SKIP 1                      
    WRITE 'ENDING NAME:   ' NAME
  END-ENDPAGE                   
END-READ                        
END

Output of Program ATPEX1S:

                                EMPLOYEE REPORT                                
-------------------------------------------------------------------------------
BEGINNING NAME: LAFON                                                          
          NAME                 FIRST-NAME              CITY         DEPARTMENT 
                                                                       CODE    
  --------------------    -------------------- -------------------- ---------- 
                                                                               
  LAFON                   CHRISTIANE           PARIS                VENT18     
  LANDMANN                HARRY                ESCHBORN             MARK29     
  LANE                    JACQUELINE           DERBY                MGMT02     
  LANKATILLEKE            LALITH               FRANKFURT            PROD22     
  LANNON                  BOB                  LINCOLN              SALE20     
  LANNON                  LESLIE               SEATTLE              SALE30     
  LARSEN                  CARL                 FARUM                SYSA01     
  LARSEN                  MOGENS               VEMMELEV             SYSA02     
------------------------------------------------------------------------------ 
                                                                               
ENDING NAME:    LARSEN

Equivalent reporting-mode example: ATPEX1R.