next up previous contents
Next: Special Variables Up: Reports Previous: Field Lines

Report Headings

Format statements for a report heading use the same format as the detail line format statement, except that _TOP is appended to the file handle. In the case of STDOUT, you must specify STDOUT_TOP. Simply using _TOP will not work.

To add a heading to the report about the CD collection, you might use the following format statement (

format STDOUT_TOP =

  @||||||||||||||||||||||||||||||||||||  Pg @<

  "CD Collection of David Marshall",       

  Album              Artist            Price

  -----------------  ----------------  -------


Adding this format statement to last code listing produces this output:

      CD Collection of David Marshall       Pg 1
  Album              Artist               Price
  -----------------  ----------------    -------
  A Love Supreme                           $ 0.00
  A Kind of Blue     Miles Davis           $ 9.99
  Koln Concert       Keith Jarrett         $ 15.99
  Birds of Fire      Mahvishnu Orchestra   $ 10.99

Whenever a new page is generated, the heading format is automatically invoked. Normally, a page is 60 lines long. However, you can change this by setting the $= special variable.

Another special variable, $%, holds the current page number. It will be initialized to zero when your program starts. Then, just before invoking the heading format, it is incremented so its value is one. You can change $% if you need to change the page number for some reason.