12. Report-Writer Statements : Text Positioning Statements : .Center Statement—Center the Text : Description
 
Share this page                  
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.