12. Report-Writer Statements : Column and Block Statements : .Within/.Endwithin Statements—Enable/Disable Column Formatting Mode : Examples
 
Share this page                  
Examples
1. Assume the following sequence of Report-Writer statements, where two of the column names are delimited identifiers:
.position "last name"(0), "first name"(16), address(32)
                ...
.within "last name", "first name", address
                .pr w_name
.end within
Report-Writer prints the names of the three columns similar to this:
last name       first name      address
2. In the following example, the .within statements allow Report-Writer to print each column of the report in a similar format.
In the report header and footer section, a .block statement allows the centered titles and sums to use more than one line. In the detail section, only one line is used so a .block statement is not necessary. In the detail and the footer section for the report, the special name w_column is used.
      Total
 Population            18 to 65
 11,113,976           9,600,381
  5,193,669           4,820,324
  8,875,083           7,833,474
 10,652,017           9,646,997
    712,567             698,802
    694,409             663,043
 19,953,134          17,761,032
    [detail omitted]
‑----------         -----------
203,165,702         177,612,309
The following report example was used to create the two columns:
.name withinex
.query select tot_18to65 + tot_under18 + tot_over65
   as totpot, tot_18to65
   from pop
.header report
   .position totpot (2,15), tot_18to65(20,15)
   .format totpop, tot_18to65 ('zzz,nnn,nnn')
   .block
       .within totpop
           .right .println 'Total'
           .underline
           .right .println 'Population'
           .nounderline
       .endwithin
       .within tot_18to65
           .newline
           .underline
           .right
           .println '18 to 65'
           .nounderline
       .endwithin
   .endblock
.detail
       .within totpop, tot_18to65
           .right  .      println w_column
       .endwithin
.footer report
   .block
       .within totpop, tot_18to65
           .right  .      println '-----------'
           .right  .      print sum(w_column)
       .endwithin
   .endblock