7.17 Using Preport

If you wanted to look at the contents of a visual reportfile, you could use rptedit or wtrdef, or you could use an alternative program, preport which is another C/Base program designed to work with visual reportfiles. Preport may be used to produce a simple text description of visual reportfile, a 'dump' of the reportfile's contents, or the Report Writer code for a text reportfile which may subsequently (if written to a file) be processed in order to produce the desired output. By means of either of the latter two, preport may be used to move report files to another computer system. (For more information, see C/Base Utilities Manual Chapter 6, Transferring C/Base Applications.)

Since visual reportfiles are not text files, and cannot be read or written by any text editor, preport is used to produce a description of a reportfile's contents which can be displayed on a terminal, printed on a printer, or written to another file in ASCII format.

Preport is the program executed when choice L2 of the Report Generator Menu is selected to list report definitions of visual reports. However, like the other programs highlighted in this chapter, preport may be invoked by issuing it as a direct command. The syntax of this command is:

c:\> preport [-dr] rptfile [textfile]

The normal (i.e., default) output generated by this command is a simple text description of the reportfile stored in the file named in the rptfile argument.

The -d option of preport indicates that the output should be in the 'dump' format instead of the default text description format.

The -r option of preport indicates that the Report Writer language format is wanted instead of the default text description format.

The last argument, textfile, is also optional, but may be used to name a file in which preport is to store its output. Without this argument, the output is instead displayed on your terminal.

As an example, suppose you wanted to view a description of the reportfile, demo~newmag, created earlier. You would use the command:

c:\> preport demo~newmag

and the output displayed would look like:

Contents of report file demo~newmag

|----------------------------------Page Heading------------------------------------------- |

|M a g a z i n e L i s t XXXXXXXXX Page X |

| XXXXX |

| |

| Magazine Magazine Title Yearly Rate Subscribers |

| |

|---------------------------------Level 1 Heading---------------------------------------- |

|---------------------------------------Detail------------------------------------------------ |

| |

| XXXXXXXXXX XXXXXXXXXXXXXXXXX XXXXXXXX XXXXX |

|------------------------------- Level 1 Footing------------------------------------------- |

|---------------------------------Page Footing--------------------------------------------- |

|--------------------------------Report Footing-------------------------------------------- |

| |

| _______ |

| XXXXXX |

|----------------------------------------------------------------------------------------------- |

Data File: mag

Sorted by: magazine

Page Heading

|------------------------------------------------------------------------------------------- |

1 | M a g a z i n e L i s t XXXXXXXX Page X |

2 | XXXX |

3 | |

4 | Magazine Magazine Title Yearly Rate Subscribers |

|------------------------------------------------------------------------------------------- |

Line 1, Column 55, Field name: $todays_date ,Field length 8

Line 1, Column 75, Field name: $page ,Field length 1

Line 2, Column 55, Field Name: $todays_time ,Field length 5

Detail:

|------------------------------------------------------------------------------------------- |

1 | XXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXX XXXXX |

|------------------------------------------------------------------------------------------- |

Line 1, Column 1, Field name: magazine ,Field length 15

Line 1, Column 18, Field name: title ,Field length 35

Line 1, Column 57, Field name: year_rate ,Field length 8

Line 1, Column 72, Field name: subscribers ,Field length 5

Report Footing:

|------------------------------------------------------------------------------------------- |

1 | ----------- |

2 | XXXXXX |

|------------------------------------------------------------------------------------------- |

Line 2, Column 71, Sum of subscribers ,Field length 6

The first page shows the name of the report with all the Report Sections, as well as all of the information from the Report Description form. The following pages go through the report by sections, first showing a picture of the section and then listing the fields contained in that section, along with their print format. The information regarding these fields is taken from the Field Description forms.

Preport may also be used to display the contents of a visual reportfile in the Report Writer language format. This is done using the -r flag when executing preport. The command entered would be:

c:\> preport -r demo~newmag

and the output would appear as:

FILE report IS "mag"

FIELDS IN report ARE

subscribers, year_rate, title, magazine;

VARIABLE

sum1 TOTAL OF subscribers;

PROCEDURE page_head

BEGIN

PRINT TAB(17), "M a g a z i n e", TAB(35), "L i s t", TAB(55),

$todays_date:8, TAB (70), "Page", TAB (75), $page:1, NL;

PRINT TAB (55), $todays_time:5, NL;

PRINT NL;

PRINT "Magazine", TAB(18), "Magazine Title", TAB(55), "Yearly Rate",

TAB (70), "Subscribers",NL;

END

PROCEDURE detail

BEGIN

PRINT report.magazine:15, TAB(18), report.title:35, TAB(57),

report.year_rate:8, TAB (72), report.subscribers:5, NL;

END

PROCEDURE report_foot

BEGIN

PRINT TAB (71), "-----", NL;

PRINT TAB (71), sum1:6, NL;

END

MAIN

BEGIN

AT TOP OF PAGE

DO page_head;

AT BOTTOM OF REPORT

DO report_foot;

SELECT FROM report

SORTED BY magazine;

FOR EACH report

DO detail;

END

Preport may also be used to create a new text reportfile, containing Report Writer code, from an existing visual reportfile. This new reportfile (named in the textfile argument) can then be read and written by any text editor that reads and writes standard ASCII files. It can also be used by grace to produce a report identical (assuming that no modifications have been made) to that which would have been produced by using the visual reportfile created by rptedit, toolkit, or wtrdef. This is an extremely powerful feature which is available to the toolkit user with the menu choice M2-Convert Visual Report to Text. Its power lies primarily in the fact that modifications (specifically, those modifications which incorporate programming changes that are not possible with visual reports) can be made to the reportfile using statements which are unique to the Report Writer programming language.

Although, as stated earlier, the -r flag may also be used to port reportfiles from one system to another, once in this form there is no way to convert Report Writer code back into a visual reportfile. Therefore, in order to create visual reportfiles on other systems, you must use the -d flag to dump the reportfile's contents to an ASCII file. The command entered would be:

c:\> preport -d demo~newmag newmag.d

If you were to then view the contents of newmag.d, the output would look like:

r:mag:66:80:4:63

s:magazine

$

1:17:t:M a g a z i n e L i s t

1:55:e:$today_date:8:0

1:70:t:Page

1:75:e:$page:1:0

2:55:e:$todays_time:5:0

4:1:t:Magazine Magazine Title Year Rate Subscribers

$

$

1:1:e:magazine:15:0

1:18:e:title:35:0

1:57:e:year_rate:8:0

1:72:e:subscribers:5:0

$

$

$

1:71:t:-----

2:71:s:subscribers:6:0

You could then use the creport(C-1) program to convert the file (in this case, newmag.d) back into a visual reportfile. (For more information, see the C/Base Utilities Manual Chapter 6, Transferring C/Base Applications and the creport command in Chapter 12, C/Base Commands.)