A format specification provides explicit editing information. An asterisk (*) as a format identifier in an input/output statement indicates list-directed formatting (13.6).
where fs is a format specification, as described in 13.2. The statement must be labeled.
A character format specification must be of the form described in 13.2. Note that the form begins with a left parenthesis and ends with a right parenthesis. Character data may follow the right parenthesis that ends the format specification, with no effect on the format specification. Blank characters may precede the format specification.
If the format identifier is a character array name, the length of the format specification may exceed the length of the first element of the array; a character array format specification is considered to be a concatenation of all the array elements of the array in the order given by array element ordering (5.2.4). However, if a character array element name is specified as a format identifier, the length of the format specification must not exceed the length of the array element.
( [flist] )
where flist is a list(2.10). The forms of the flist items are:
The comma used to separate list items in the list flist may be omitted as follows:
The forms of a repeatable edit descriptor are:
Iw Iw.m Fw.d Ew.d Ew.dEe Dw.d Gw.d Gw.dEe Lw A Aw
The forms of a nonrepeatable edit descriptor are:
'h1 h2 ... hn' nHh1h2 ... hn Tc TLc TRc nX / : S SP SS kP BN BZ
If an input/output list specifies at least one list item, at least one repeatable edit descriptor must exist in the format specification. Note that an empty format specification of the form ( ) may be used only if no list items are specified; in this case, one input record is skipped or one output record containing no characters is written. Except for an edit descriptor preceded by a repeat specification, r ed, and a format specification preceded by a repeat specification, r(flist), a format specification is interpreted from left to right. A format specification or edit descriptor preceded by a repeat specification r is processed as a list of r format specifications or edit descriptors identical to the format specification or edit descriptor without the repeat specification. Note that an omitted repeat specification is treated the same as a repeat specification whose value is one.
To each repeatable edit descriptor interpreted in a format specification, there corresponds one item specified by the input/output list (12.8.2), except that a list item of type complex requires the interpretation of two F, E, D, or G edit descriptors. To each P, X, T, TL, TR, S, SP, SS, H, BN, BZ, slash, colon, or apostrophe edit descriptor, there is no corresponding item specified by the input/output list, and format control communicates information directly with the record.
Whenever format control encounters a repeatable edit descriptor in a format specification, it determines whether there is a corresponding item specified by the input/output list. If there is such an item, it transmits appropriately edited information between the item and the record, and then format control proceeds. If there is no corresponding item, format control terminates.
If format control encounters a colon edit descriptor in a format specification and another list item is not specified, format control terminates.
If format control encounters the rightmost parenthesis of a complete format specification and another list item is not specified, format control terminates. However, if another list item is specified, the file is positioned at the beginning of the next record and format control then reverts to the beginning of the format specification terminated by the last preceding right parenthesis. If there is no such preceding right parenthesis, format control reverts to the first left parenthesis of the format specification. If such reversion occurs, the reused portion of the format specification must contain at least one repeatable edit descriptor. If format control reverts to a parenthesis that is preceded by a repeat specification, the repeat specification is reused. Reversion of format control, of itself, has no effect on the scale factor (13.5.7), the S, SP, or SS edit descriptor sign control (13.5.6), or the BN or BZ edit descriptor blank control (13.5.8).
After each T, TL, TR, X, or slash edit descriptor is processed, the file is positioned as described in 13.5.3 and 13.5.4.
If format control reverts as described in 13.3, the file is positioned in a manner identical to the way it is positioned when a slash edit descriptor is processed (13.5.4).
During a read operation, any unprocessed characters of the record are skipped whenever the next record is read.
A field is a part of a record that is read on input or written on output when format control processes one I, F, E, D, G, L, A, H, or apostrophe edit descriptor. The field width is the size in characters of the field.
The internal representation of a datum corresponds to the internal representation of a constant of the corresponding type (Section 4).
The width of the field is the number of characters contained in, but not including, the delimiting apostrophes. Within the field, two consecutive apostrophes with no intervening blanks are counted as a single apostrophe.
Note that if an H edit descriptor occurs within a character constant and includes an apostrophe, the apostrophe must be represented by two consecutive apostrophes, which are counted as one character in specifying n.
The position specified by a T edit descriptor may be in either direction from the current position. On input, this allows portions of a record to be processed more than once, possibly with different editing.
The position specified by an X edit descriptor is forward from the current position. On input, a position beyond the last character of the record may be specified if no characters are transmitted from such positions.
On output, a T, TL, TR, or X edit descriptor does not by itself cause characters to be transmitted and therefore does not by itself affect the length of the record. If characters are transmitted to positions at or after the position specified by a T, TL, TR, or X edit descriptor, positions skipped and not previously filled are filled with blanks. The result is as if the entire record were initially filled with blanks.
On output, a character in the record may be replaced. However, a T, TL, TR, or X edit descriptor never directly causes a character already placed in the record to be replaced. Such edit descriptors may result in positioning so that subsequent editing causes a replacement.
The TLc edit descriptor indicates that the transmission of the next character to or from the record is to occur at the character position c characters backward from the current position. However, if the current position is less than or equal to position c, the TLc edit descriptor indicates that the transmission of the next character to or from the record is to occur at position one of the current record.
The TRc edit descriptor indicates that the transmission of the next character to or from the record is to occur at the character position c characters forward from the current position.
On input from a file connected for sequential access, the remaining portion of the current record is skipped and the file is positioned at the beginning of the next record. This record becomes the current record. On output to a file connected for sequential access, a new record is created and becomes the last and current record of the file.
Note that a record that contains no characters may be written on output. If the file is an internal file or a file connected for direct access, the record is filled with blank characters. Note also that an entire record may be skipped on input.
For a file connected for direct access, the record number is increased by one and the file is positioned at the beginning of the record that has that record number. This record becomes the current record.
The S, SP, and SS edit descriptors affect only I, F, E, D, and G editing during the execution of an output statement. The S, SP, and SS edit descriptors have no effect during the execution of an input statement.
where k is an optionally signed integer constant, called the scale factor.
The scale factor k affects the appropriate editing in the following manner:
The BN and BZ edit descriptors affect only I, F, E, D, and G editing during execution of an input statement. They have no effect during execution of an output statement.
On input, an Iw.m edit descriptor is treated identically to an Iw edit descriptor.
In the input field, the character string must be in the form of an optionally signed integer constant, except for the interpretation of blanks (13.5.9, item (1)).
The output field for the Iw edit descriptor consists of zero or more leading blanks followed by a minus if the value of the internal datum is negative, or an optional plus otherwise, followed by the magnitude of the internal value in the form of an unsigned integer constant without leading zeros. Note that an integer constant always consists of at least one digit.
The output field for the Iw.m edit descriptor is the same as for the Iw edit descriptor, except that the unsigned integer constant consists of at least m digits and, if necessary, has leading zeros. The value of m must not exceed the value of w. If m is zero and the value of the internal datum is zero, the output field consists of only blank characters, regardless of the sign control in effect.
The input field consists of an optional sign, followed by a string of digits optionally containing a decimal point. If the decimal point is omitted, the rightmost d digits of the string, with leading zeros assumed if necessary, are interpreted as the fractional part of the value represented. The string of digits may contain more digits than a processor uses to approximate the value of the constant. The basic form may be followed by an exponent of one of the following forms:
An exponent containing a D is processed identically to an exponent containing an E.
The output field consists of blanks, if necessary, followed by a minus if the internal value is negative, or an optional plus otherwise, followed by a string of digits that contains a decimal point and represents the magnitude of the internal value, as modified by the established scale factor and rounded to d fractional digits. Leading zeros are not permitted except for an optional zero immediately to the left of the decimal point if the magnitude of the value in the output field is less than one. The optional zero must appear if there would otherwise be no digits in the output field.
The form of the input field is the same as for F editing (220.127.116.11.1).
The form of the output field for a scale factor of zero is:
[+]  . x1x2...xd exp
____________________________________________________ | | | | | Edit | Absolute Value | Form of | | Descriptor | of Exponent | Exponent | |____________|__________________|__________________| | | | | | Ew.d | |exp|<=99 | E+z z or +0z z | | | | 1 2 1 2 | | |__________________|__________________| | | 99<|exp|<=999 | +z z z | | | | 1 2 3 | |____________|__________________|__________________| | | | | | Ew.dEe | |exp|<=(10**e)-1 | E+z z ...z | | | | 1 2 e | |____________|__________________|__________________| | | | | | Dw.d | |exp|<=99 | D+z z or E+z z | | | | 1 2 1 2 | | | | or + z z | | | | 1 2 | | |__________________|__________________| | | 99<|exp|<=999 | +z z z | | | | 1 2 3 | |____________|__________________|__________________|
where z is a digit. The sign in the exponent is required. A plus sign must be used if the exponent value is zero. The forms Ew.d and Dw.d must not be used if |exp| > 999.
The scale factor k controls the decimal normalization (13.5.7). If -d < k <= 0, the output field contains exactly |k| leading zeros and d - |k| significant digits after the decimal point. If 0 < k < d + 2, the output field contains exactly k significant digits to the left of the decimal point and d - k + 1 significant digits to the right of the decimal point. Other values of k are not permitted.
G input editing is the same as for F editing (18.104.22.168.1).
The method of representation in the output field depends on the magnitude of the datum being edited. Let N be the magnitude of the internal datum. If N < 0.1 or N >= 10**d, Gw.d output editing is the same as kPEw.d output editing and Gw.dEe output editing is the same as kPEw.dEe output editing, where k is the scale factor currently in effect. If N is greater than or equal to 0.1 and is less than 10**d, the scale factor has no effect, and the value of N determines the editing as follows:
__________________________________________________ | | | | Magnitude of Datum | Equivalent Conversion | |________________________|_______________________| | | | | 0.1=N<=1 | F(w-n).d, n('b') | | | | | 1<=N<10 | F(w-n).(d-1), n('b') | | . | . | | . | . | | . | . | | | | | 10**(d-2)<=N<10**(d-1) | F(w-n).1, n('b') | | | | | 10**(d-1)<=N<10**d | F(w-n).0, n('b') | |________________________|_______________________|where:
Note that the scale factor has no effect unless the magnitude of the datum to be edited is outside of the range that permits effective use of F editing.
The output field consists of w - 1 blanks followed by a T or F, as the value of the internal datum is true or false, respectively.
If a field width w is specified with the A edit descriptor, the field consists of w characters. If a field width w is not specified with the A edit descriptor, the number of characters in the field is the length of the character input/output list item.
Let len be the length of the input/output list item. If the specified field width w for A input is greater than or equal to len, the rightmost len characters will be taken from the input field. If the specified field width is less than len, the w characters will appear left-justified with len-w trailing blanks in the internal representation.
If the specified field width w for A output is greater than len, the output field will consist of w-len blanks followed by the len characters from the internal representation. If the specified field width w is less than or equal to len, the output field will consist of the leftmost w characters from the internal representation.
Each value is either a constant, a null value, or of one of the forms:
where r is an unsigned, nonzero, integer constant. The r*c form is equivalent to r successive appearances of the constant c, add the r* form is equivalent to r successive appearances of the null values. Neither of these forms may contain embedded blanks, except where permitted within the constant c.
A value separator is one of the following:
When the corresponding input list item is of type real or double precision, the input form is that of a numeric input field. A numeric input field is a field suitable for F editing (22.214.171.124) that is assumed to have no fractional digits unless a decimal point appears within the field.
When the corresponding list item is of type complex, the input form consists of a left parenthesis followed by an ordered pair of numeric input fields separated by a comma, and followed by a right parenthesis. The first numeric input field is the real part of the complex constant and the second is the imaginary part. Each of the numeric input fields may be preceded or followed by blanks. The end of a record may occur between the real part and the comma or between the comma and the imaginary part.
When the corresponding list item is of type logical, the input form must not include either slashes or commas among the optional characters permitted for L editing (13.5.10).
When the corresponding list item is of type character, the input form consists of a nonempty string of characters enclosed in apostrophes. Each apostrophe within a character constant must be represented by two consecutive apostrophes without an intervening blank or end of record. Character constants may be continued from the end of one record to the beginning of the next record. The end of the record does not cause a blank or any other character to become part of the constant. The constant may be continued on as many records as needed. The characters blank, comma, and slash may appear in character constants.
Let len be the length of the list item, and let w be the length of the character constant. If len is less than or equal to w, the leftmost len characters of the constant are transmitted to the list item. If len is greater than w, the constant is transmitted to the leftmost w characters of the list item and the remaining len-w characters of the list item are filled with blanks. Note that the effect is as though the constant were assigned to the list item in a character assignment statement (10.4).
A null value is specified by having no characters between successive value separators, no characters preceding the first value separator in the first record read by each execution of a list-directed input statement, or the r* form. A null value has no effect on the definition status of the corresponding input list item. If the input list item is defined, it retains its previous value; if it is undefined, it remains undefined. A null value may not be used as either the real or imaginary part of a complex constant, but a single null value may represent an entire complex constant. Note that the end of a record following any other separator, with or without separating blanks, does not specify a null value.
A slash encountered as a value separator during execution of a list-directed input statement causes termination of execution of that input statement after the assignment of the previous value. If there are additional items in the input list, the effect is as if null values had been supplied for them.
Note that all blanks in a list-directed input record are considered to be part of some value separator except for the following:
The processor may begin new records as necessary, but, except for complex constants and character constants, the end of a record must not occur within a constant and blanks must not appear within a constant.
Logical output constants are T for the value true and F for the value false.
Integer output constants are produced with the effect of an Iw edit descriptor, for some reasonable value of w.
Real and double precision constants are produced with the effect of either an F edit descriptor or an E edit descriptor, depending on the magnitude x of the value and a range 10**d1 <= x < 10**d2, where d1 and d2 are processor-dependent integer values. If the magnitude x is within this range, the constant is produced using OPFw.d; otherwise, 1PEw.dEe is used. Reasonable processor-dependent values of w, d, and e are used for each of the cases involved.
Complex constants are enclosed in parentheses, with a comma separating the real and imaginary parts. The end of a record may occur between the comma and the imaginary part only if the entire constant is as long as, or longer than, an entire record. The only embedded blanks permitted within a complex constant are between the comma and the end of a record and one blank at the beginning of the next record.
Character constants produced are not delimited by apostrophes, are not preceded or followed by a value separator, have each internal apostrophe represented externally by one apostrophe, and have a blank character inserted by the processor for carriage control at the beginning of any record that begins with the continuation of a character constant from the preceding record.
If two or more successive values in an output record produced have identical values, the processor has the option of producing a repeated constant of the form r*c instead of the sequence of identical values.
Slashes, as value separators, and null values are not produced by list-directed formatting.
Each output record begins with a blank character to provide carriage control when the record is printed.