[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

10.10.3 Fitting Reports on the Page

If you need more columns than physically can fit on a page, you can do the following:

  • Eliminate as many unused spaces as possible between columns. Columns should not be run together; however, you can use one blank space instead of several.
  • Eliminate nonessential information.
  • Print two or more lines with staggered headers and columns.
  • Print two reports.

10.10.4 Printing Totals Before Detail Lines

A report that must include totals at the top of the page before the detail lines has three solutions as follows:

  • Store the logical print lines in a table, total the table, and then print from the table.
  • Pass through the file twice. The first time, compute the totals. The second time, print the report. This method is slow and complicated if there are many subtotals.
  • Write the lines into a file with a sort key containing the report, page, and line number. When your program writes the last line and computes the total, have it assign a page and line number to the total line's sort key. Use an appropriate page and line number to cause the total line to sort in front of its detail lines. After the program completes, sort the file, read it, drop the sort key, and produce the report.

10.10.5 Underlining Items in Your Reports

The examples in this section apply only to printers that support overprinting.

Sometimes you must underline a column of numbers to denote a total and also underline the total to highlight it:


1234
1122
----
2356
====

To print a single underline, use the underscore character and suppress line spacing. For example:


WRITE PRINT-LINE FROM SINGLE-UNDERLINE-TOTAL
                 BEFORE ADVANCING 0 LINES.

This overprints the underscore (_) on the previous line, underlining the item: 1122. Use the equal sign (=) to simulate double underlines. Note that you must write the equal signs on the next line. For example:


WRITE PRINT-LINE FROM DOUBLE-UNDERLINE-TOTAL
                 AFTER ADVANCING 1 LINE.

10.10.6 Bolding Items in Your Reports

The examples in this section apply only to printers that support overprinting.

To bold an entire line in a report:

  1. Write the line as many times as you want, specifying the BEFORE ADVANCING 0 LINES phrase (three times is sufficient). This darkens the line but does not advance to the next line.
  2. Write the line one last time without the BEFORE ADVANCING phrase. This overprints the line again and advances to the next print line.

For example:


WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
WRITE PRINT-LINE FROM TOTAL-LINE.

This example produces a darker image in the report. You can use similar statements for characters and words, as well as complete lines. To bold only a word or only a character within a line, you must:

  1. Write the print line and specify the BEFORE ADVANCING 0 LINES phrase.
  2. Use reference modification to create a skeleton line containing only the items in the print line you want bolded.
  3. Write the skeleton line as many times as you want and specify the BEFORE ADVANCING 0 LINES phrase. This darkens the items in the skeleton line but does not advance to the next line.
  4. Write the skeleton line one last time without the BEFORE ADVANCING phrase. This overprints the line again and advances to the next print line.

For example:


    WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
*
* Move spaces over the items in the source print line (TOTAL-LINE)
* that are not to be bolded
*
    MOVE SPACES TO ...
    WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
    WRITE PRINT-LINE FROM TOTAL-LINE BEFORE ADVANCING 0 LINES.
    WRITE PRINT-LINE FROM TOTAL-LINE.


Chapter 11
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms

ACCEPT and DISPLAY statements are used to make low-volume data available to specified devices. You will find the following information useful:

  • Section 11.1 describes the use of the ACCEPT and DISPLAY statements for interactive I/O.
  • Section 11.2 explains how you can design an online video form similar to a printed form by using the Hewlett-Packard extensions to the ACCEPT and DISPLAY statements.
  • Section 11.3 describes the X/Open Screen Section features. You can use it to design video forms easily and efficiently in a single section of your COBOL program, and then accept or display a full screen of data with a single ACCEPT statement or DISPLAY statement.

11.1 Using ACCEPT and DISPLAY for I/O

The COBOL language provides two statements, ACCEPT and DISPLAY, for low-volume I/O operations. The ACCEPT and DISPLAY statements transfer data between your program and the standard input and output devices. If you do not use the FROM or UPON phrases, or an environment variable, the default device for ACCEPT is the keyboard and the default device for DISPLAY is the terminal screen.

The FROM or UPON phrases refer to mnemonic names that you can define in the Environment Division SPECIAL-NAMES paragraph. You define a mnemonic name by equating it to a COBOL implementor name; for example, the following clause equates STATUS-REPORT to the device LINE-PRINTER:


LINE-PRINTER IS STATUS-REPORT

You can then use the mnemonic name in a DISPLAY statement:


DISPLAY "File contains " REC-COUNT UPON STATUS-REPORT.

The COBOL implementor names in the SPECIAL-NAMES paragraph refer to special HP COBOL environment variables or logical names. Environment variables or logical names do not always represent physical devices.

On the Tru64 UNIX operating system, you can assign an environment variable to a file name as follows:


% setenv COBOL_LINEPRINTER status.lis   <>

On OpenVMS, you can assign a logical name to a file specification using the ASSIGN command (or the DEFINE command, with the arguments in reverse order):


$ ASSIGN [ALLSTATUS]STATUS.LIS COB$LINEPRINTER   <>

If you use an environment variable or a logical name, you must define it appropriately for the ACCEPT or DISPLAY statement to succeed.

On OpenVMS, when you run an application, if input and output are both directed to terminals, they must be directed to the same terminal. If input and output are directed to different terminals, the output terminal is used and the input terminal is ignored. <>

For more information on the logical names or environment variables and the mnemonic names, refer to the SPECIAL-NAMES section in the Environment Division chapter in the HP COBOL Reference Manual.

ACCEPT Statement

On OpenVMS, the ACCEPT statement transfers data from the input device to a data item. If you do not use the FROM phrase, the system uses the logical name COB$INPUT if it is defined, otherwise SYS$INPUT. If you use the FROM phrase, it uses the logical name associated with the mnemonic-name in the FROM clause. <>

On Tru64 UNIX, the ACCEPT statement transfers data from the input device to a data item. If you do not use the FROM phrase, the system uses the environment variable COBOL_INPUT if it is defined, or stdin if COBOL_INPUT is not otherwise defined. If you use the FROM phrase, the system uses the environment variable associated with the mnemonic-name in the FROM clause. <>

The following example illustrates the FROM phrase used in conjunction with ACCEPT:


SPECIAL-NAMES.
    CARD-READER IS WHATS-THE-NAME
    .
    .
    .
PROCEDURE DIVISION.
    .
    .
    .
    ACCEPT PARAMETER-AREA FROM WHATS-THE-NAME.

DISPLAY Statement

On OpenVMS, the DISPLAY statement transfers the contents of data items and literals to the output device. If you do not use the UPON phrase, the system uses the logical name COB$OUTPUT if it is defined, or SYS$OUTPUT if it is not defined. If you use the UPON phrase, the system uses the logical name associated with the mnemonic-name in the FROM clause. <>

On Tru64 UNIX, the DISPLAY statement transfers the contents of data items and literals to the output device. If you do not use the UPON phrase, the system uses the environment variable COBOL_OUTPUT if it is defined, or stdout if it is not defined. If you use the UPON phrase, the system uses the environment variable associated with the mnemonic-name in the UPON clause.


Previous Next Contents Index