.Position Statement--Set Position and Width of Column Output
The .position statement sets a default output position and optional width associated with a column.
This statement has the following format:
.position | .pos columnname {, columnname} (position [,width])
{, columnname{, columnname} (position [, width])}
The parameters for the .position statement are as follows:
columnname
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.
position
Numeric location on the output line where the default column position should be. This value must be less than the maximum line size (as set by the .pagewidth statement in the report specification or by the ‑l flag on the report command line) and greater than or equal to zero (0).
width
The default width which is the total number of characters in the column to be used when calculating the positioning for .center and .right statements. If not specified, Report-Writer determines this numeric by looking at the default format for the column.
The columnname, position, and width can be expressed as variables. The comma (,) and parentheses ( ) must be explicitly stated and cannot be part of the columnname, position, or width variable.
$columnvariable
Variable whose value is the name for a column in the report. Precede the variable with a dollar sign ($).
$positionvariable
Variable whose value is the numeric location on the output line where the default column position should be. This variable must evaluate to a position less than the maximum line size (as set by the .pagewidth statement in the report specification or by the ‑l flag on the report command line) and greater than or equal to zero (0).
$widthvariable
Variable whose value is the default width, which is the total number of characters in the column to be used when calculating the positioning for .center and .right statements. If not specified or evaluated, Report-Writer determines this value by looking at the default format for this column.
Description
The .position statement sets a default position in the output line associated with a column name for use with statements such as:
.left
.right
.center
.tab
You can also use this statement to set an optional default width (the total number of characters in a column) when calculating positions in the .center and .right statements.
If you specify a variable for columnname, position, and/or width, Report-Writer evaluates the variable during the loading of the report specification, before retrieving any report data.
Normally, you do not need this statement because Report-Writer determines default positions and widths by analyzing the report formatting statements. If the determined default position for a column is not convenient, or you would like a different position associated with a columnname, you can override the default with the .position statement. Subsequently, you can use the .tab, .right, .left, or .center statements with a columnname to refer to this position.
If you do not specify a .position statement for a column, and columnname is not printed in the report, the default position is zero (0). If you specify a position, but no width is specified or evaluated for a column, Report-Writer determines the default width by looking at the default format for the column. You can optionally use the .width statement to specify the width of a column.
Examples
1. The following example sets up default positions for columns, and prints out the data. The column "acct num" is a delimited identifier.
.position "acct num"(5), transact(20), balance(35)
.format transact, balance ('$,$$$,$$$.nn')
.format "acct num"('nn-nnnnn-n')
...
.tab acct .print acct
.tab transact .print transact
.tab balance .print balance
.newline
This results in a printout like this:
01-02234-4 $1,345.24 $11,429.32
02-41989-1 $876.24 $10,553.08
2. To vary the column positions and widths, use variables:
.position "acct num"($acct_pos, $acct_width),
transact ($transact_pos, $transact_width),
balance ($balance_pos, $balance_width)
Last modified date: 08/28/2024