WRITE TRAILER

#### Search Results

Search

# WRITE TRAILER

`WRITE` [(rep)] `TRAILER` `[LEFT` [`JUSTIFIED`]] [`UNDERLINED`]
| [(statement-parameters )]
| n `X` |  |  |  |  |  |
n `T` |  |  |  |
x/y |  |  | 'text' [(attributes)] |
`T*`field-name |  | 'c' (n) [(attributes)]
`P*`field-name |  | [`'='`] operand1 [(parameters )]
`/` |  |  |  |
| [`SKIP` operand2 [`LINES`]] |  |

This document covers the following topics:

- WRITE TRAILER Usage

- WRITE TRAILER Restrictions

- WRITE TRAILER Syntax Description

- WRITE TRAILER Example

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

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

Belongs to Function Group: Creation of Output Reports

## WRITE TRAILER Usage

The `WRITE TRAILER` statement is used to output text or the contents of variables at the bottom of a page.

See also the following sections (in the Programming Guide):

- Report Format and Control

- Report Specification - (rep) Notation

- Layout of an Output Page

- Page Trailer - WRITE TRAILER Statement

- Text Notation

### Processing

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

This statement is executed when an end-of-page or end-of-data condition is detected, or when a `SKIP` or `NEWPAGE` statement causes a page advance. It is not executed as a result of an `EJECT` statement.

The end-of-page condition is checked only after the processing of an entire `DISPLAY`/`WRITE` statement. If a `DISPLAY`/`WRITE` statement produces multiple lines of output, overflow of the physical page may occur before the end-of-page condition is reached.

If a report is produced by statements in different objects, the `WRITE TRAILER` statement is only executed if it is contained in the same object as the statement that causes the end-of-page condition.

### Logical Page Size

The logical page size (specified with the session parameter `PS`) should be less than the physical page size to ensure that the trailer information appears at the bottom of the same page.

## WRITE TRAILER Restrictions

- `WRITE TRAILER` may be specified only once per report.

- `WRITE TRAILER` cannot be specified within a special condition statement block.

- `WRITE TRAILER` cannot be specified within a subroutine.

## WRITE TRAILER Syntax Description

Operand Definition Table:

Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition
--- | --- | --- | --- | ---
operand1 |  | S | A | G | N | A | U | N | P | I | F | B | D | T | L |  | G | O | yes | no
operand2 | C | S |  |  |  |  |  | N | P | I |  | B |  |  |  |  |  |  | yes | no

Syntax Element Description:

Syntax Element | Description
--- | ---
`(rep)` | Report Specification: If multiple reports are to be produced, the notation `(rep)` may be used to specify the identification of the report for which the `WRITE TRAILER` statement is applicable. As report identification, 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 `WRITE TRAILER` statement applies to the first report (Report 0). For information on how to control the format of an output report created with Natural, see Report Format and Control (in the Programming Guide).
`LEFT JUSTIFIED` `UNDERLINED` | Title Justification and/or Underlining: By default, the trailer lines are centered and not underlined. `LEFT JUSTIFIED` and `UNDERLINED` may be specified to override these defaults. If `UNDERLINED` is specified, the underlining character (either default or specified with the session parameter `UC`) is printed underneath the trailer and runs the width of the line size (session parameter `LS`). Natural first applies all spacing or tab specifications and creates the line before centering the whole line. For example, a notation of `10T` as the first element would cause the centered header to be positioned five positions to the right.
`statement-parameters` | Parameter Definition at Statement Level: One or more parameters, enclosed within parentheses, may be specified at statement level, that is, immediately after the `WRITE TRAILER` statement. Each parameter specified in this manner will override the corresponding parameter previously specified in a `GLOBALS` command, `SET GLOBALS` (in Reporting Mode only) or `FORMAT` statement. If more than one parameter is specified, one or more blanks must be present between each entry. An entry may not be split between two statement lines. Note The parameter settings applied here will only be regarded for variable fields, but they have no effect on text-constants. If you would like to set field attributes for a text-constant, they have to be set explicitly for this element, see Parameter Definition at Element (Field) Level. For information on which parameters may be used, see List of Parameters (in the `WRITE` statement documentation).
`nX` `nT` `x/y` `T*field-name` `P*field-name` `/` | Format Notation and Spacing Elements: See Format Notation and Spacing Elements (below).
`'text'` `'c'(n)` `attributes` | Text/Attribute Assignments: See Text/Attribute Assignments (below).
`operand1` | Trailer Information: `operand1` represents the field/fields to be output as trailer information.
`parameters` | Parameter Definition at Element (Field) Level: One or more parameters, enclosed within parentheses, may be specified at element (field) level, that is, immediately after `operand1`. Each parameter specified in this manner will override the corresponding parameter previously specified at statement level or in a `GLOBALS` command, `SET GLOBALS` (in Reporting Mode only) or `FORMAT` statement. If more than one parameter is specified, one or more blanks must be present between each entry. An entry may not be split between two statement lines. For information on which parameters may be used, see List of Parameters in the `WRITE` statement documentation.
`SKIP operand2 LINES` | Lines to Be Skipped: `SKIP` may be used to cause lines to be skipped immediately after the trailer line. The number of lines to be skipped (`operand2`) may be specified as a numeric constant or as the content of a numeric variable. Note `SKIP` after `WRITE TRAILER` is always interpreted as the `SKIP` clause of the `WRITE TRAILER` statement, and not as an independent statement. If you wish an independent `SKIP` statement after a `WRITE TRAILER` statement, use a semicolon (;) to separate the two statements from one another.

#### Format Notation and Spacing Elements

Syntax Element | Description
--- | ---
`nX` | Column Spacing: This notation inserts `n` spaces between columns.
`nT` | Tab Setting: The `nT` notation causes positioning (tabulation) to print position `n`. Backward positioning is not permitted.
`x/y` | x/y Positioning: Causes the next element to be placed x lines below the output of the last statement, beginning in column y. y must not be zero. Backward positioning in the same line is not permitted.
`T*field-name` | Field-Related Positioning: The `T*` notation causes positioning to a specific print position of a field used in a previous `DISPLAY` statement. Backward positioning is not permitted.
`P*field-name` | Field- and Line-Related Positioning: The `P*` notation causes positioning to a specific print position and line of a field used in a previous `DISPLAY` statement. It is most often used in conjunction with vertical printing mode. Backward positioning is not permitted.
`/` | Line Advance - Slash Notation: When placed between fields or text elements, a slash (/) causes positioning to the beginning of the next print line.

#### Text/Attribute Assignments

Syntax Element | Description
--- | ---
`'text'` | Text Assignment: The character string enclosed by single quotes is displayed.
`'c'(n)` | Character Repetition: The character enclosed by single quotes is displayed n times immediately before the field value.
`attributes` | Field Representation and Color Attributes: It is possible to assign various attributes for text/field display. These attributes and the syntax that may be used are described in the section Output Attributes below. Examples:
    WRITE TRAILER 'TEXT' (BGR)
    WRITE TRAILER 'TEXT' (B)
    WRITE TRAILER 'TEXT' (BBLC)

#### Output Attributes

attributes indicates the output attributes to be used for text display. Attributes can be:

| `AD`=ad-value `CD`=cd-value `PM`=pm-value |
| ad-value cd-value |

Where:

`ad-value`, `cd-value` and `pm-value` denote the possible values of the corresponding session parameters `AD`, `CD` and `PM` described in the relevant sections of the Parameter Reference documentation.

The compiler actually accepts more than one attribute value for an output field. For example, you can specify: `AD=BDI`. In such a case, however, only the last value applies. In the given example, only the value `I` becomes effective and the output field is displayed intensified.

For an alphanumeric/Unicode constant (Natural data format A or U), you can specify `ad-value` and/or `cd-value` without preceding `CD=` or `AD=`, respectively. The single value entered is then checked against all possible `CD` values first. For example: a value of `IRE` will be interpreted as intensified/red but not as intensified/right-justified/mandatory. You cannot combine a single `cd-value` or `ad-value` with a value preceded by `CD=` or `AD=`.

## WRITE TRAILER Example

    ** Example 'WTLEX1': WRITE (with TRAILER option)
    ************************************************************************
    DEFINE DATA LOCAL
    1 EMPL-VIEW VIEW OF EMPLOYEES
      2 NAME
      2 FIRST-NAME
      2 CITY
      2 JOB-TITLE
    END-DEFINE
    *
    FORMAT PS=15
    WRITE TITLE LEFT JUSTIFIED UNDERLINED
          *TIME 3X 'PEOPLE LIVING IN BARCELONA'
          14X 'PAGE:' *PAGE-NUMBER
    SKIP 1
    *
    WRITE TRAILER LEFT JUSTIFIED UNDERLINED
          / 'CITY OF BARCELONA REGISTER'
    *
    LIMIT 10
    FIND EMPL-VIEW WITH CITY = 'BARCELONA'
      DISPLAY NAME FIRST-NAME 3X JOB-TITLE
    END-FIND
    END

#### Output of Program WTLEX1 - Page 1:

    09:36:09.5   PEOPLE LIVING IN BARCELONA              PAGE:      1
    -------------------------------------------------------------------------------

            NAME              FIRST-NAME                 CURRENT
                                                        POSITION
    -------------------- --------------------   -------------------------

    DEL CASTILLO         ANGEL                  EJECUTIVO DE VENTAS
    GARCIA               M. DE LAS MERCEDES     SECRETARIA
    GARCIA               ENDIKA                 DIRECTOR TECNICO
    MARTIN               ASUNCION               SECRETARIA
    MARTINEZ             TERESA                 SECRETARIA
    YNCLAN               FELIPE                 ADMINISTRADOR
    FERNANDEZ            ELOY                   OFICINISTA
    TORRES               ANTONI                 OBRERA

    CITY OF BARCELONA REGISTER
    -------------------------------------------------------------------------------

#### Output of Program WTLEX1 - Page 2:

    09:37:26.0   PEOPLE LIVING IN BARCELONA              PAGE:      2
    -------------------------------------------------------------------------------

            NAME              FIRST-NAME                 CURRENT
                                                        POSITION
    -------------------- --------------------   -------------------------

    RODRIGUEZ            VICTORIA               SECRETARIA
    GARCIA               GERARDO                INGENIERO DE PRODUCCION

    CITY OF BARCELONA REGISTER
    -------------------------------------------------------------------------------

### On this page

- WRITE TRAILER Usage
- WRITE TRAILER Restrictions
- WRITE TRAILER Syntax Description
- WRITE TRAILER Example