Automatic Determination of Default Settings
If you have not explicitly specified them, Report-Writer calculates default settings for the right and left margins of the report, for the starting position and width of each column (for use with statements such as .tab and .right), and/or for the formats to use when printing columns. Report-Writer determines the default settings on the basis of an analysis of the other report formatting statements, which are performed after the report set up and page layout statements (such as .leftmargin), but before the first printing of the report.
Analysis of Report Formatting Statements
To determine default values, Report-Writer analyzes the formatting statements in reverse hierarchical order, from the innermost (detail level) statements to the outermost (report level) statements, as shown below:
1. .detail section statements
2. .footer statements for innermost sort column
3. .header section for innermost sort column
4. .footer and .header sections for the next to the last sort column, and so on
5. .footer and .header text for the page
6. .footer and .header text for the report
By analyzing the report code in this way, Report-Writer attempts to determine the innermost references to columns in the report, and to determine the leftmost and rightmost print positions indicated by the specified report formatting statements.
How Default Page Width Is Determined
For default reports—that is, a report based on a table, as in the command, report mydb tblname—the page width default is 80 characters if the report is displayed on the screen, or 132 characters if the report is written to a file or sent to the printer. You can override the default with the .pagewidth statement.
How Default Margins Are Determined
If you explicitly specify the margins for the report with the .leftmargin and .rightmargin statements, these values are used. Otherwise, Report-Writer determines the minimum and maximum print positions for a line in the report while scanning the report formatting statements. If only one of the margins is explicitly stated, Report-Writer determines the other one during the scan. Report-Writer uses margins derived in this manner to determine line positions for the .center, .right, or .left statements, when these statements are used without specified parameters.
How Default Column Positions Are Determined
If you do not specify a .position statement for a column, Report-Writer determines the column's default position for use with the .tab, .right, .left, or .center statements from the analysis of report formatting statements. Report-Writer determines default column positions by the first print position it encounters that has been specified for the printing of a value in that column or for an aggregate of that column.
Reports are usually set up in such a way that the innermost printing of column values occurs in the .detail statements of the report. Items such as column headers and aggregates, which print in the header or footer text for a break, can then use the .tab or another positioning statement in relation to the default position for the innermost position of a column. If you want to change the position of a column and its associated heading and/or aggregates, you must change the innermost print position for the column. Because all references to headers and aggregates are given in relative terms, Report-Writer changes their positions automatically.
As an example, see Account Example in the appendix "Report-Writer Report Examples." The default position for the amt column is determined by the cumulative aggregate for amt.
How Default Column Formats Are Determined
If you do not specify a .format statement for a column, Report-Writer determines the column's default format in a manner similar to that used for determining the default column position. Report-Writer uses the innermost reference to a format for a column, or to an aggregate for a column, as the default format for a column. If you do not specify any formats for a column, Report-Writer determines defaults from the data type of the column, as described in Default Formats in the chapter "Report-Writer Expressions and Formats."
The default format for a column is best used in situations where you specify the format in the reference to a column in the .detail formatting statements. Aggregates of that column are specified in the footers for some of the breaks. Report-Writer then correctly uses the format you specified in the .detail section for the aggregates.
However, the .format statement is often quite useful for specifying a series of columns that are given the same format. For a good illustration of the use of the .format statement for this purpose, see Population Example in the appendix "Report-Writer Report Examples."
How Default Column Widths Are Determined
If you do not specify a .width statement or width parameter to the .position statement for a given column, Report-Writer determines the default column width by the default format for that column, as specified by the .format statement or as determined from the analysis of report formatting statements. The default width of a column is the width required by the column format to print a value. Report-Writer uses the column width to determine the print positions for the .right or .center statements.
Last modified date: 01/30/2023