OADL Format Specifiers

An OADL Format Specifier is a string that contains one or more Format Descriptors, separated by commas. There are three types of Format Descriptors, Format Value Descriptors, Format Flag Descriptors, and Other Format Descriptors. Format Value Descriptors describe values to be printed or read. Format Flag Descriptors describe flags that control how values are printed and read. Other Format Descriptors cause input/output cursor control, literal items, and other commands.

Whitespace is ignored in a Format Specifier outside of embedded literals. Any Format Value Descriptor may be prefixed with an optional Repeat Count, which implies N identical Format Value Descriptors.

The following table describes the possible Format Value Descriptors (FVDs). In this table, the following definitions are used:

The Precision and Exponent Width are ignored for formatted reads.

The case of FVDs is significant only for the l, i, z, e, en, es, g, m, y and v FVDs. For them, a lower-case Descriptor causes the output characters to be entirely lower-case.

FVD Width Prec. Exp. Description
L opt Logical (boolean) format descriptor. If the field width is 5 or greater (or automatic), prints TRUE or FALSE. Otherwise, prints T or F.
A opt String format descriptor
I opt opt Integer format descriptor. Prints in base 10 unless a different radix is specified with the R format descriptor.
Z opt opt Hexadecimal integer format descriptor
O opt opt Octal integer format descriptor
B opt opt Binary integer format descriptor
F opt opt Floating point format descriptor
M opt opt Monetary floating point format descriptor
E opt opt opt Exponential floating point format descriptor
EN opt opt opt Engineering notation floating point format descriptor
ES opt opt opt Scientific notation floating point format descriptor
G opt opt opt Generalized floating point format descriptor
Y opt opt opt Hexadecimal floating point format descriptor
V opt opt opt Variable format descriptor. Print in L, I, G, or A format, depending on item type

For scalar values, each FVD correponds to a single item. For arrays, each FVD corresponds to a column of the array. All items in a column in an array will have the same field width; if the field width is omitted, the maximum field width will be calculated sufficient to hold all items in a column. All rows will be horizontally aligned, even between separate arrays. If this behavior is not desired, the | or S| Format Flag Descriptors may be used.

Output of nested arrays, enclosures, and strings with whitespace will cause a character-graphic box to be drawn around the item. If all of the characters of the output buffer are ASCII, the ASCII characters +-| will be used to draw the box. Otherwise, the following Unicode characters will be used to draw the box:

Code Char Descrption
0x250C Top left corner
0x2500 Horizontal line
0x2510 Top right corner
0x2502 Vertical line
0x2514 Bottom left corner
0x2518 Bottom right corner

To disable box output, use the SN# Format Flag Descriptor. To force Unicode box drawing characters to be used, use the SW Format Flag Descriptor.

The following table describes the possible Format Flag Descriptors (FFD):

FFD Description
SP Add '+' to positive numbers (disable with SNP or SS)
SB Add a single leading blank to positive numbers (disable with SS)
S# Enable box output around arrays (disable with SN#)
SU Treat integers as unsigned (disable with SNU)
SV Add type information prefix/suffix and quotes (disable with SNV)
ST Add thousands separator (disable with SNT)
S| Enable auto row break - don't align rows horizontally bewtween printed values (disable with SN|)
SL Left-justify output items in their field (disable with SR)
SC Center output items in their field (disable with SR)
SR Right-justify output items in their field (default)
SF'c' Set monetary fill character to c
SI Use international money symbols (disable with SNI)
S* Put single-line literals in all rows (disable with SN*)
SW Force WideChar output (cannot be disabled)
S or SN Same as SNP,SNB,SN#,SNU,SNV,SNT,SN|,SR,SNI,SN*

The following table describes the possible Other Format Descriptors (OFD):

OFD Description
count X Horizontal space. If the optional count is omitted, defaults to 1. Same as count TR.
radix R Radix control for the I format descriptor. If the optional radix is omitted, defaults to 10. Radixes from 2 to 36 may be specified.
rep (fmt) Nested format specifier. The repeat count rep is optional.
"literal" Prints the literal string literal. Two double-quotes adjacent to each other "" do not terminate the literal, but will print as an individual double-quote "
'literal' Prints the literal string literal. Two single-quotes adjacent to each other '' do not terminate the literal, but will print as an individual single-quote '
: Output terminator. If no more values remain to print, literals after the terminator will not print.
* Format reversion point. If there are more values to print than format descriptors, repeat the format descriptors starting at this point
$ Suppress newline
| Row break - don't align rows horizontally across this breakpoint
/, //, etc. Advance output rows. The number of slashes dictates the number of rows to advance.
T pos Absolute horizonal position
TL delta Relative horizontal position (toward the left)
TR delta Relative horizontal position (toward the right). Same as deltaX

As a historical note, OADL Format Specifiers are very similar to FORTRAN format statements. The differences include:

The following is the complete BNF description of OADL Format Specifiers:

format          : fmt_item
                | fmt_item ',' format
                ;

opt_int         : INT           // Repeat N times
                |               // No repeat
                ;

fmt_item        : INT rep_item
                | opt_int rep_fmt_char
                | opt_int '(' format ')'
                | non_rep_item
                ;

rep_fmt_char    : prec_fmt_char opt_int opt_digits
                | exp_fmt_char opt_int opt_digits opt_expon
                | 'L' opt_int           // Logical
                | 'A' opt_int           // String
                | 'X'                   // Space
                | 'R'                   // Radix control
                ;

opt_digits      : '.' INT
                |               // No digits
                ;

opt_expon       : 'E' INT
                | 'e' INT
                |               // No exponent
                ;

prec_fmt_char   : 'I' | 'Z' |'O' // Integer formats
                | 'i' | 'z'     // Ext. - lower case radix print
                | 'B'           // Ext. - integer binary (from Fortran 90)
                | 'F'           // Floating point format
                ;

exp_fmt_char    : 'E' | 'G'     // Exponential & Generic
                | 'e' | 'g'     // Extension - print lower-case
                | 'E' 'S' | 'e' 's' // Scientific notation
                | 'E' 'N' | 'e' 'n' // Extension - engineering (from F90)
                | 'Y' | 'y'     // Extension - like printf("%a")
                | 'V' | 'v'     // Extension - print according to var type
                | 'M'           // Extension - monetary float format
                ;

non_rep_item    : '\'' chars '\'' // Literal
                | '"' strchars '"' // Literal
                | ':'           // Terminate if no more items
                | '*'           // Reversion point
                | '$'           // Suppress newline
                | '|'           // Row break
                | advance       // Advance one or more output rows
                | 'S' | 'S' 'N' // Same as SNP,SNV,SNT,SN$,SJ
                | 'S' 'P'       // Add '+' to positive nums
                | 'S' 'S'       // Suppress '+' from positive nums
                | 'S' 'N' 'P'   // Extension - same as SS
                | 'S' 'B'       // Extension - same as printf("% d")
                | 'S' '#'       // Extension - enable box output around arrays
                | 'S' 'N' '#'   // Extension - disable box output around arrays
                | 'S' 'U'       // Extension - treat integers as unsigned
                | 'S' 'N' 'U'   // Extension - disable integers as unsigned
                | 'S' 'V'       // Extension - add type info pre/suf and quotes
                | 'S' 'N' 'V'   // Extension - disable type info pre/suf and quotes
                | 'S' 'T'       // Extension - add thousands separator
                | 'S' 'N' 'T'   // Extension - disable thousands separator
                | 'S' '|'       // Extension - enable auto row break
                | 'S' 'N' '|'   // Extension - disable auto row break
                | 'S' 'L'       // Extension - left-justified in field
                | 'S' 'C'       // Extension - center item in field (ign. field sign)
                | 'S' 'R'       // Extension - return to right-justified formatting
                | 'S' 'F' '\'' ch '\'' // Extension - set monetary fill char
                | 'S' 'I'       // Extension - use international monetary symbol
                | 'S' 'N' 'I'   // Extension - use national monetary symbol
                | 'S' '*'       // Extension - put single-line literals in all rows
                | 'S' 'N' '*'   // Extension - only put literals in first row
                | 'S' 'W'       // Extension - force wide char output (sticky)
                | 'T' INT       // Absolute horizontal position
                | 'T' 'L' INT   // Relative horizontal pos (toward left)
                | 'T' 'R' INT   // Relative horizontal pos (toward right)
                ;

advance         : '/'           // Advance one output row
                | advance '/'   // Advance multiple output rows
                ;

chars           : /* NOTHING */
                | chars CHAR
                | chars '\'' '\''
                ;

strchars        : /* NOTHING */
                | strchars CHAR
                | strchars '\"' '\"'
                ;

Back to Input / Output

Continue to Predefined Symbols

Return to Introduction