Was this helpful?
Data Positioning, Formatting, and Printing
Report-Writer relies on three different groups of statements to print data in the correct place and format. These are:
Column and block default setting statements
Text positioning statements
Print statements
You use these statements to:
Set default print positions and widths for columns
Position text explicitly, or left justify, right justify, or center column values within the margins defined by the column defaults
Define the print format (for instance, character string or decimal) for the value to be printed
Print an explicit value or print the next value in a column at the previously defined position, in the designated format
The following discussions describe the process of positioning, formatting, and printing data in more detail.
Note:  Column defaults can be explicitly defined with the column and block or other statements noted previously. If defaults are left undefined, Report-Writer automatically determines the defaults from an analysis of your report code. See Automatic Determination of Default Settings. Explicitly set defaults override any automatically determined ones.
Default Print Positions for Columns
Before you can print a value, indicate where it must be printed. As noted previously, Report-Writer automatically determines default column print positions from an analysis of the other report formatting statements. However, if you want to set up your own defaults, you can do so with the following column and block statements:
.position
.width
Using the .position statement, you can effectively set up margins for each column. This statement allows you to set the starting print position for a column and optionally, the width of the printed column in number of characters. You can also set the width of a column with the .width statement. All horizontal print positions start at 0 (left margin).
To print columns horizontally adjacent to each other, you must reference the column names within the same .print statement, separated by commas. If possible, Report-Writer can print the columns next to each other, at the positions specified in the .position statement(s) or at default print positions.
In some cases, however, the following block statements can be used to exercise more control over the printing of horizontally adjacent text:
.block and .endblock
.top
.bottom
.within and .endwithin
The .block and .endblock statements allow you to define a block of formatting and print statements to be treated as a unit. Then, you can use the .top or .bottom statements to reset the current line to the top or bottom of the defined block before processing the next statement. The .within and .endwithin statements temporarily set the report margins to the margins for a referenced column. This allows you to print text (such as the caption, Total) within the column margins without having to calculate the exact print position.
For details, see Column and Block Statements in the chapter "Report-Writer Statements."
Text Positioning
In addition to the column and block default‑setting statements, you generally use another group of statements, called text positioning statements, to tell Report-Writer how to position the text or data in relation to the default position. The text positioning statements are:
.tab
.newline
.left
.center
.right
.lineend
.linestart
You can use the .tab statement with a column name to tab to the assigned print position for that column before issuing a .print statement. In addition to tabbing, text positioning statements allow you to center or justify text within the default column margins, or to position text at the beginning or end of a line or on another line.
You can also use the text positioning statements with explicit values (instead of column names) or variables for the tab setting, left and right justify positions, and so on. Explicitly set positions override column defaults.
For details, see Text Positioning Statements in the chapter "Report-Writer Statements."
The Print Format
The appearance of the text or data in your report is controlled by the format specification. For instance, the c format indicates a character string format and the e format causes a value to be printed in scientific notation. You can also specify the format with a template such as $zz,zzz.nn, containing characters with special meanings, which define the way a value is to be printed.
The print format can be specified in the .print statement, or can be used in a .format statement to set a default print format for a column, as in the code fragment:
.format emp (c12), sal ('$zz,zzz,zzn.nn')
.print emp,sal
The results might look like this:
Jones      $  109,224.00
Smith      $  32,575.00
You can temporarily override a default column format with the .tformat statement to print the next value only in a different format. After the value is printed, the format returns to the original default type. This is useful for printing a dollar sign only once at the start of a page, for instance.
You can also override a default format by specifying the format as a parameter in the .print statement, as in this example:
.print salary ('zz,zzz,zzn.nn')
This code fragment causes Report-Writer to print salary values in the specified format, without the dollar sign, until it encounters another format or print statement for this column. For more information on print formats, see Format Specifications in the chapter "Report-Writer Expressions and Formats."
To indicate underlining of text or values, use the .underline and .nounderline statements. Any .print statements located between the .underline and .nounderline statements can produce underlined text. By default, the underline character is the underscore (_) for reports written to a file (reports written to the screen do not display underlining). You can change the default to any other character, using the .ulcharacter statement. All underline characters are printed on the line below the text, except for the underscore (_) character, which appears on the same line as the text. For more information on underlining, see Print Statements in the chapter "Report-Writer Statements
How the Printed Value Is Determined
The actual text or value to be printed is specified as an expression in the .print statement syntax. The expression can be a column name, a constant, a function, an aggregate, a runtime report variable such as the current date and time, or a variable whose value is specified in a .declare or .let statement or on the command line, with or without a prompt.
By default, Report-Writer prints an empty string when it encounters a null value. You can change this default to any string of characters, using the .nullstring statement. For instance, you can tell Report-Writer to print the string "none" wherever it finds a null value in the data.
For more information on the .print and .nullstring statements, see Print Statements in the chapter "Report-Writer Statements."
Last modified date: 11/28/2023