Was this helpful?
.Block/.Endblock Statements--Enable/Disable Block Mode
The .block and .endblock statements enable and disable block mode, which lets you refer to positions on previous and subsequent lines in the report.
This statement has the following format:
.block | .blk
      formatting statements
.endblock | .endblk | .end block
Description
The .block and .endblock statements switch Report-Writer into and out of block mode, allowing you to use advanced capabilities of Report-Writer in formatting complex reports. While in block mode, you can move not only across the page (through the .tab statement) and down the page (through the .newline statement), but also back up the page (through the .top statement).
Block mode gives you the capability of logically printing information in your report, and then putting summary information ahead of the detailed information. Do this by switching Report-Writer into block mode, printing out some number of lines, moving to the top of the block to add summary information, and then printing out the entire block by leaving block mode.
By using this statement in conjunction with the .within and .endwithin statements, described later in this chapter, you can describe column headings and subtotaling in a more natural and convenient fashion than is possible if you had to describe each line completely before going to the next line.
All formatting statements are allowed within block mode, except for the .newpage and .need statements. Additionally, you can use the .top and .bottom statements only while in block mode to move the current position within the block.
Report-Writer permits a default maximum of 310 explicit .newline statements within any one block, as protection against misspecified columns. You can override this default by setting the ‑wmxwrap parameter in the report command.
Examples
1. Assume the following sequence of Report-Writer statements:
.block
      .print 'Line 1' .newline
      .print 'Line 2' .newline
      .top
      .tab 10 .pr 'more line 1' .newline
.endblock
You would get the following output:
Line 1 more line 1
Line 2
2. Assume the following sequence of Report-Writer statements:
.sort region, state
.header region
      .need 4
      .block
          .print 'Region: ', region .nl
.detail
      .tab 5
      .print state(c15)
      .tab 30
      .print tot_18to65('n,nnn,nnn')
      .newline
.footer region
      .top
      .lineend
      .tab + 5
      .print 'Count of states: '
      .println count(state) (f3)
.end block
You would get the following output:
Region: East South Central  Count of states:  4
Alabama                     2,528,938
Kentucky                    2,971,232
Mississippi                 1,393,283
Tennessee                   3,283,432
Region: Mountain            Count of states:  8
Arizona                     1,604,948 
Colorado                    2,112,352 
Idaho                       0,698,802 
Montana                     0,663,043 
Nevada                      0,448,177 
New Mexico                  0,915,815 
Utah                        1,031,926 
Wyoming                     0,323,024
Last modified date: 08/28/2024