The general form of a FORMAT statement follows: FORMAT (q1 f1s1 f2s2 ... fnsn qn) qn Is zero or more slash (/) record terminators. fn Is a data edit descriptor, a control edit descriptor, or a group of data or control edit descriptors enclosed in parentheses. sn Is a field separator (a comma or slash). A comma can be omitted in the following cases: o Between a P edit descriptor and an immediately following F, E, EN, ES, D, or G edit descriptor. o Before a slash (/) record terminator (if there is no optional repeat specification) o After a slash (/) record terminator. o Before or after a colon (:) edit descriptor. In data transfer I/O statements, a format specifier ([FMT=]format) can be a character expression that is a character array, character array element, or character constant. This type of format is also called a run-time format because it can be constructed or altered during program execution. The expression must evaluate to a character string whose leading part is a valid format specification (including the enclosing parentheses). Variable format expressions must not appear in this kind of format specification.
1 – Data Edit Format
A data edit descriptor takes one of the following forms: [r]c [r]cw [r]cw.m [r]cw.d [r]cw.d[Ee] r Is an optional repeat count. (If you omit "r", the repeat count is assumed to be 1.) c Is a format code (I,B,O,Z,F,E,EN,ES,D,G,L, or A). w Is the total number of digits in the field (the field width). m Is the minimum number of digits that must appear in the field (including leading zeros). d Is the number of digits to the right of the decimal point. E Identifies an exponent field. e Is the number of digits in the exponent. The ranges for "r", "w", "m", "d", and "e" are as follows: Term Range ---- __________ r 1 to 2147483647 (2**31-1) w 1 to 2147483647 m 0 to 32767 (2**15-1) d 0 to 32767 e 1 to 32767 The terms must all be positive, unsigned, integer constants or variable format expressions. You cannot use PARAMETER constants for "r", "w", "m", "d", or "e".
2 – Control Edit Format
A control edit descriptor takes one of the following forms: c nc cn c Is a format code (X, T, TL, TR, SP, SS, S, BN, BZ, P, /, '...', "...", Q, \, $, or :). n Is an optional number of character positions. The term "n" must be a positive, unsigned, integer constant or a variable format expression. For all format codes (except P), the value of "n" must be within the range 1 through 2147483647 (2**31-1); actual useful ranges may be constrained by record sizes (RECL) and the file system. The P edit descriptor is an exception to the general control edit descriptor syntax. It is preceded by a scale factor, rather than a character position specifier. The value of "n" for P must be within the range -128 to 127. Control edit descriptors can be grouped in parentheses and preceded by a group repeat specification.
3 – Character String Format
The character string edit descriptors are the character constant and H edit descriptor. The character constant edit descriptor ('string' or "string") causes string to be output to an external record. (For more information on the H edit descriptor, see FORMAT H in online Help.) Although no string edit descriptor can be preceded by a repeat specification, a parenthesized group of string edit descriptors can be preceded by a repeat specification.