Was this helpful?
.Right Statement--Right Justify the Text
The .right statement right justifies the next text to be printed.
This statement has the following format:
.right | .rt [[+|-] n | columnname | expression]
The parameters for the .right statement are as follows:
+ | -
If sign is present, the position is moved n positions relative to the last output position. If no sign is present, the position is the absolute position in the output line.
n
The position to which the next block of text is right justified. The default value is the right margin of the report (set by the .rightmargin statement).
columnname
The name of a column in the report. You can specify the column name as a delimited identifier by enclosing it within double quotes ("), if you have previously specified the .delimid statement.
Report-Writer determines the column's position either explicitly through the use of the .position statement, or implicitly as described in Automatic Determination of Default Settings. Report-Writer right justifies the text in the next .print statement to the right edge of that column, as determined from the default position and width of that 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 next print position on the line. 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 .right statement right justifies the text printed in the next .print statement to one of the following locations:
Specified position
Position corresponding to a specified column
Value of a numeric expression that evaluates to a specified position
Value of a string expression or variable that evaluates to a column name
Report-Writer evaluates any expressions that are used as parameters to the .right statement during runtime.
You can specify all the values for these parameters as either absolute or relative to the last output. Report-Writer removes all leading and trailing blanks from the text before placing the text in the output line.
If you specify n or a numeric expression that evaluates to n (either relative or absolute), Report-Writer right justifies the text to that position. If you specify nothing, Report-Writer right justifies the text to the right margin of the report. Report-Writer determines the right margin either from the .rightmargin statement, if specified, or by default as described in Automatic Determination of Default Settings.
If you specify right justification with the columnname parameter or through a string expression that evaluates to a columnname, Report-Writer right justifies the text to the right edge of that column, as determined from the following:
Default position of the column, as determined from the .position statement or by default
Width of the column, as determined by the default width or the width of the format specified in a .format statement for that column, or by the width specified in .width or the .position statements
The .right statement justifies to a position calculated as:
justification position =
default column position + default width
The meaning of the .right statement is slightly changed when the .right statement is executed within column formatting mode (that is, when the .within statement is in effect and default column widths and positions are assumed). When the .right statement is so executed without a parameter, the current position becomes the right margin as defined by the .within statement, not the right margin of the report. For more information about column formatting mode, see the .within/.endwithin statements.
Examples
1. Output a page number, right justified on the right margin.
.right
.print 'Page ', page_number('zn')
2. Output a heading for column "bal," right justified to the right edge of the column.
.position bal (20)
.format bal('+++,+++.nn')
.right bal .print 'Balance'
           ...
.detail
        ...
    .tab bal .print bal ...
        ...
Last modified date: 01/30/2023