⎕FMT Wish List

17 views
Skip to first unread message

Brian McGuinness

unread,
May 15, 2022, 8:40:07 PMMay 15
to
O modifier:
Allow the number to be omitted, in which case it defaults to zero.

Allow the replacement text to be omitted, in which case it defaults to zero.

Now 'O' by itself causes zeroes to be replaced with blanks, as 'B' does now. This moves all of the number replacements under the same modifier, 'O', and frees up 'B' for another use.

B modifier:
The new syntax is Bn, where n is an integer from 2 to 16 specifying the radix to display an integer value in. This applies to the 'I' and 'G' formats. The letters from 'A' to 'F' are normally used for "digits" from 10 to 15, but this can be changed by using the 'S' modifier, e.g. S<AaBbCcDdEeFf> for base 16 or S<ATBE> for base 12.

C modifier:
Allow an optional integer to follow the 'C' to specify the spacing of the commas (e.g. C4 separates groups of 4 digits). The default spacing is 3. This is useful when the radix is not 10, e.g. 'C4B16I'

G format:
Add the concept of a "stop character." Filling in a 'G' format spec from right to left, when a stop character is encountered it is not inserted in the output. Instead, it serves as a marker. If there are no more digits left to insert, everything to the left of the stop character is converted to blanks. The stop character may appear in multiple places in the format spec. The default stop character is '?', but this can be changed by the 'S' modifier. For example:

NARS2000:

'G<(ZZZ) 999-9999>' ⎕FMT 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 12345678901
( 000 0001
( 000 0012
( 000 0123
( 000 1234
( 001-2345
( 012-3456
( 123-4567
( 1) 234-5678
( 12) 345-6789
(123) 456-7890
**************

Using '?' as a stop character, and including all background text that is surrounded by digits:

'G<(ZZZ) ?999-9999>' ⎕FMT 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 12345678901
000-0001
000-0012
000-0123
000-1234
001-2345
012-3456
123-4567
( 1) 234-5678
( 12) 345-6789
(123) 456-7890
**************

V (variable) format:
This proposed new format would be similar to Fortran G format of C printf() "%g". Since the letter 'G' is already in use, I propose using 'V' instead. The idea is that fixed point output is more intuitively meaningful than scientific notation, since the number of digits to the left of the decimal point or the number of leading zeroes to the right immediately gives a sense of the size of the number. But if the number won't fit in the field in fixed point notation, using scientific notation is infinitely preferable to displaying a meaningless row of asterisks.

= modifier:
This is like 'L', but instead of left-justifying the number in the field it centers the number in the field.

Other changes:

Omitting the field width from a format spec causes ⎕FMT to use the minimum field with that would allow the contents of the corresponding column of data to fit.

All relevant modifiers (such as C, K, M, N, O, P, Q) are taken into account when calculating this width.
Reply all
Reply to author
Forward
0 new messages