Skip to content

Line-Counter

LINE-COUNTER is an internal special register that contains the most recent report line number on which data was produced, or which has been advanced to by a blank LINE clause or a NEXT GROUP clause. LINE-COUNTER may also be altered by an ordinary PROCEDURE DIVISION statement or implicitly by Report Writer SET statements.

line counter

Uses of Line-Counter

LINE-COUNTER is a special register giving the current vertical position on the page. After a GENERATE has been executed, LINE-COUNTER will be set to the line number of the last line occupied by the last group output. A NEXT GROUP may change it further (see NEXT GROUP clause). You can test the value of LINE-COUNTER to determine the vertical position on the current page.

Whenever you issue a GENERATE statement, report writer examines LINE-COUNTER to decide where it should output the lines of the group. It is set to zero by the INITIATE and by a page advance. Then, if your line has a LINE + integer clause, report writer uses (LINE-COUNTER + integer) as its target line. When the page-fit test is performed for a relative body group, report writer adds the size of your group to LINE-COUNTER to see whether the last line will be below the group's lower limit.

Note

You may alter the value of LINE-COUNTER in the PROCEDURE DIVISION, but take care! Do not reduce the value of LINE-COUNTER, or you are liable to cause too many lines to be written to your page so that it overflows its lower limit. You may increase its value safely.

Some legitimate reasons for altering its value are:

  • To create an additional gap between the previous group and the next group: ADD size-of-gap TO LINE-COUNTER

    If your page is nearly full (so that LINE-COUNTER is nearly equal to the LAST DETAIL value) this will simply cause a page advance upon the next GENERATE instead of a gap. If your ADD statement sets LINE-COUNTER below LAST DETAIL, no harm is done. You should note that the NEXT GROUP clause performs this function more elegantly.

  • To cause a page advance, that is, to force report writer to place no more body groups on this page, code: MOVE page-limit TO LINE-COUNTER. Again, coding the NEXT GROUP NEXT PAGE clause on the previous group also performs this function better. (See NEXT GROUP clause.)

  • If your REPORT SECTION has several Report Descriptions, each will have its own distinct LINE-COUNTER. In the main-line PROCEDURE DIVISION, you will therefore need to qualify LINE-COUNTER by the name of the report. (See PAGE-COUNTER, and Multiple Reports.)

Compatibility

  • OS/VS and DOS/VS COBOL also allow LINE-COUNTER to be altered explicitly, but this does not create a gap.

  • OS/VS and DOS/VS COBOL Report Writer require LINE-COUNTER to be qualified wherever it is used if your program contains more than one RD.

Back to top