reporttbl

Usage: reporttbl [options] file.frm

Formats and prints an arbitrary style report, with the format specified in the file "file.frm". A page header may be specified.

This RDB operator reads an rdbtable from STDIN and writes a formatted report on STDOUT. Options may be abbreviated.

Options:

The "file.frm" file (or form file) shows pictorially one 'record' of output, which will contain data from one row of an rdbtable. An optional page header may be defined as well.

The form file contains regular text, picture fields, and associated column names. Regular text prints just as given. Picture fields define the width and justification for printing a data value from a column. The names of the associated columns are listed on the line following the picture fields and in the same order. Note that this file should not contain any TAB characters; space characters should be used instead.

Picture fields start with either '@' or '^' and are followed by one of three primary characters to define the width of the field. The three characters are '<', '>', or '|' to specify left, right, or center justification respectively. There is also an alternate right justification character for printing numeric data, with optional decimal point. The character is the sharp sign '#', and a period specifies the decimal point placement, as in '@########.##'.

A numeric picture field has the following features:

Numeric Data may be in the form of integers, fixed point, or scientific notation' e.g. 12345, 4567.345, or 1.678E17.

Normally picture fields start with the '@' character. That means to put the referenced data value into the defined picture field, or as much of the data as will fit into the field, if the data is larger than the field. If the field starts with the '^' character it means to repeat the field on as many lines as necessary in order to print the entire data value. This is useful for large data fields, such as comments or free text.

Instead of a column name there are some special names that can be used to have other information inserted. This are especially useful if there is a page header. The special names and what they mean are:

An example of a form file for use with rdbtable 'sample' is shown in Table 13.

The first and last lines (that start with 'format' or a single period) define the pictorial records and must be as shown. The first record defines the header and is optional. If this form file (named sample.frm) were used in the command:

        reporttbl  sample.frm  <  sample
it would produce the one page report as in Table 14.

For another example, one might want to have a date on a report in other than the standard date output format, and an idea of who executed the program, and have a reference count of the records being produced. The form file might be as in Table 15. which could produce:

                                Table 13

                    FORM FILE FOR RDBTABLE (SAMPLE)

format top =
Page @>,            The Page Header     @<<<<<<<<<<<<<<<<<<<<<<<<<<<
   _pgnr_                                       _date_

.
format =
  Name:   @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<          Type:  @>>>>
               NAME                                 	     TYP
                  Total: @<<<<<<<<     Other:  @<<<<<<<<<<<<<<<
                         AMT                        OTHER
                                Table 14

               PRINTING RDBTABLE (SAMPLE) WITH REPORTTBL

Page  1,            The Page Header     Mon Dec  2 16:21:18 PST 1991

  Name:   Bush                                        Type:      A
                  Total: 133           Other:  Another
  Name:   Hansen                                      Type:      A
                  Total: 23            Other:  One
  Name:   Jones                                       Type:      X
                  Total: 77            Other:  Here
  Name:   Perry                                       Type:      B
                  Total: 244           Other:  And
  Name:   Hart                                        Type:      D
                  Total: 1111          Other:  So
  Name:   Holmes                                      Type:      D
                  Total: 1111          Other:  On

                                Table 15

                           ANOTHER FORM FILE

format top =
Run By: @<<<<<<<        The Date/Time is    @<<<<<<<<<<<<<<<<<<<<<<<<
        _`whoami`_                           _`date "+%m/%d/%y %H:%M"`_
.
format =
    RecordNr:  @>>      @<<<<<<<<<<<<<<<<<<<<
              _rcnr_    OTHER
.


Run By: hobbs           The Date/Time is    10/15/91 09:43

    RecordNr:    1      Other data here
    RecordNr:    2      and here,
    RecordNr:    3      and so on.
    ...         ...     ...

Another example shows how longer data values can be handled. If the form file (named sample2.frm) looks like Table 16, and if the following command is used:

        reporttbl  sample2.frm  <  sample2
then the output would be as shown in Table 17. Note that since there were two picture fields that started with the '^' character on one line the length of output records varies according to the length of the two associated data values.
                                Table 16

                    FORM FILE FOR RDBTABLE (SAMPLE2)

format top =
Page @>,                Page Header here                 @<<<<<<<<<<<<<
_pgnr_                                      _`date "+%m/%d/%y %H:%M"`_
                Executed by @<<<<<<< on: @<<<<<<<<<
                            `whoami`     _`hostname`_

format =
    Name:   @<<<<<<<<<<<<<<<  Other: @<<<<<<<<<<        Type: @<<<<<<<<
            NAME              OTHER                            TYP
 Comment:   ^<<<<<<<<<<<<<<    Long: ^<<<<<<<<<<<<<<    Right: @>>>>>>>
            COMMENT                   LONG                     RIGHT
=======================================================================
                                Table 17

               PRINTING RDBTABLE (SAMPLE2) WITH REPORTTBL

Page  1,  		Page Header here   	         12/02/91 16:32
                Executed by hobbs    on: id

    Name:   Bush              Other: Another            Type: A
 Comment:   A comment          Long: This a long        Right:     This
            here.                    message for
                                     test.
=======================================================================
    Name:   Hansen            Other: One                Type: A
 Comment:   A longer           Long: This a long        Right:       Is
            comment here.            message for
                                     test.
=======================================================================
    Name:   Jones             Other: Here               Type: X
 Comment:   A longer,          Long: Short test.        Right:       On
            longer comment
            here.
=======================================================================
    Name:   Perry             Other: And                Type: B
 Comment:   A short comment    Long: This a long        Right:      The
            here.                    message for
                                     test.
=======================================================================
    Name:   Hart              Other: So                 Type: D
 Comment:   Little here.       Long: Here too.          Right:    Right
=======================================================================
    Name:   Holmes            Other: On                 Type: D
 Comment:   A comment here     Long: A short            Right:     Edge
            that is a                message.
            little ongoing,
            so to speak.
=======================================================================