Was this helpful?
.Center Statement--Center the Text
The .center statement centers the next text to be printed.
This statement has the following format:
.center | .cen | .ce [[+|-] n | columnname | expression]
The parameters for the .center statement are listed below:
+ | -
If sign is present, the position is moved n positions relative to the last output position. If unsigned, the position is the absolute position in the output line.
n
The position around which the next block of text is centered. The default value is the halfway point between the left and right margins of the report.
columnname
The name of a column in the report. You can specify the column name as a delimited identifier by enclosing it in double quotes ("), if you have previously specified the .delimid statement.
Report-Writer determines the position for the column either explicitly through the use of the .position statement, or implicitly as described in Automatic Determination of Default Settings. Report-Writer positions the text in the next .print statement around the center for the column. For more information, see the discussion following this table.
expression
A numeric or string expression. If the expression is numeric, it must evaluate to the position around which the next block of text is centered. If the expression is a string, it must evaluate to the name of a column in the report. Precede all variables that are part of the expression with a dollar sign ($).
The plus sign (+) and minus sign (-) must be explicitly stated and cannot be part of the expression.
Description
The .center statement centers the text printed in the next .print statement. Report-Writer removes all leading and trailing blanks from the text before it places it in the output line.
Report-Writer evaluates any expressions that are used as parameters to the .center statement during runtime.
If you specify n (either relative or absolute), Report-Writer centers the text around that position. If you specify nothing, Report-Writer calculates the center of the page as the halfway point between the left and right margins of the report. If you specify .leftmargin and .rightmargin statements, you can calculate the center by the same method. However, if you are using the default values for the right and left margins (the right in particular), see Automatic Determination of Default Settings in the chapter "Using Report-Writer" for a discussion of how Report-Writer determines the margins.
If you specify centering with the columnname parameter or with an expression that evaluates to a columnname, Report-Writer centers the text in that column. Report-Writer determines the center of the column through both of the following:
Default position of the column, as determined by the .position statement or by default
Width of the column, as determined by default or by the width of the format specified in the .format statement, or as specified in the .width or the .position statements
The .center statement centers text around a position calculated as:
centering position =
default column position + (default format width / 2)
Report-Writer rounds the position to the next highest number if there is any fraction.
The .center statement has a somewhat different meaning when executed in column formatting mode (that is, inside a .within statement with default column widths and positions assumed). Because the .within statement temporarily resets the report margins to the left and right margins of a specified column's width and position, a .center statement so executed centers a text string within the column width, not within the report page margins. For more information about column formatting mode, see the .within/.endwithin statements.
Examples
1. Output the date centered on the page.
.center
.print 'Report Executed On:', current_date
2. Output a heading for a column centered above the value of that column, where the column is the delimited identifier, bank balance.
.position "bank balance" (20)
.format "bank balance"('+++,+++.nn')
        ...
.center "bank balance" .print 'Balance'
        ...
.detail
        ...
    .tab "bank balance" .print bal ...
Last modified date: 11/28/2023