fmt modifier

The fmt modifier substitutes the column heading, justification and width settings specified in "{'<column-heading>'} {<just>} {<width>}" for attributes 3, 9 and 10 of the specified Attribute-Defining-Item.

Syntax

ADIfmt "{'< column-heading>'} {< just>} {< width>}"

Parameter(s)

ADI Specifies the Attribute-Defining-Item for which the specified column-heading, just and width will be substituted for attributes 3, 9 and 10.
{'<column-heading>'} Specifies the column heading to substitute for attribute 3. The single quotes are required.
{<just>} Specifies the justification to substitute for attribute 9.
{<width>} Specifies the width to substitute for attribute 10.

Double quotes are required around the entire heading, justification and width specification.

Example(s)

Consider the following sort operation:

:sort demo.test by a1 a1
Page   1     demo.test                            16:17:03 16 Nov 2009
 
demo.test...... a1....................................................
 
1                         1
2                         10
5                         100
3                         2
4                         20
 
[405] 5 items listed out of 5 items.

Let's say we want to sort the a1 column numerically instead of alphabetically. The sort operation illustrated below accomplishes this:

:sort demo.test by a1 fmt "r5" a1
Page   1     demo.test                            16:19:47 16 Nov 2009
 
demo.test...... a1....................................................
 
1                         1
2                         2
3                         10
4                         20
5                         100
 
[405] 5 items listed out of 5 items.

It sorted correctly, but we feel the column width still is too wide and the data in the a1 column is still aligned to the left (despite the fmt "r5" specification). This is because the fmt specification only applies to how the ADI is used for that reference. In this case, we applied it to a1 only for the sort order. We still need to apply right-justification for both sort order and display format, but width for only the display. For example:

:sort demo.test by a1 fmt "r" a1 fmt "r10"
Page   1     demo.test                            16:22:50 16 Nov 2009
 
demo.test...... a1........
 
1                            1
2                            2
3                           10
4                           20
5                          100
 
[405] 5 items listed out of 5 items.

The example below illustrates running the sort operation using only a width parameter for the display. In this case, we adjusted the a1 output column width, but the default output left justification is unchanged.

:sort demo.test by a1 fmt "r" a1 fmt "20"
Page   1     demo.test                            16:28:18 16 Nov 2009
 
demo.test...... a1..............
 
1                          1
3                          2
2                          10
4                          20
5                          100
 
[405] 5 items listed out of 5 items.

The following example illustrates listing the number of orders for the products referenced in the translate statement. Note how the heading for the 2nd column uses the actual translate statement as its heading.

:list orders eval
"trans(products,productid,productname,'x')"
Page   1     orders             14:37:45 08 Apr 2010
orders.... trans(products,productid,productname,'x')

11           Ninja Graph
             Ninja Toolbox
88           Ninja Assist

Let's say that instead of using the translate statement as its heading, we want to instead specify a more user-presentable heading. The example below employs the fmt modifier in the statement to allow specifying an alternate column heading and a left-justification of 15.

:list orders eval
"trans(products,productid,productname,'x')"
fmt "'Product Name'L15"
Page   1     orders             14:37:45 08 Apr 2010
orders....  Product Name...
11           Ninja Graph
             Ninja Toolbox
88           Ninja Assist

See also

eval modifier