<format part>
──<identifier>─┬─ ( ──<editing specifications>── ) ─┬──────────────────┤
└─ < ──<editing specifications>── > ─┘<format identifier>
An identifier associated with a set of editing specifications in a FORMAT declaration.
<editing specifications>
┌◄────────────────────────┬── , ─┬─────────────────────────┐
│ └◄─ / ─┘ │
──┬─────┬─┴─┬─<simple string literal>──────────────────────────────┬─┴─►
└─ / ─┘ ├───────────────┬─┬─<editing phrase>───────────────────┤
├─<repeat part>─┘ └─ ( ──<editing specifications>── ) ─┤
│ ┌◄────┐ │
└─┴─ / ─┴──────────────────────────────────────────────┘
►─┬─────┬──────────────────────────────────────────────────────────────┤
└─ / ─┘<repeat part>
──┬─<unsigned integer>─┬───────────────────────────────────────────────┤ └─ * ────────────────┘
The editing specifications that appear in FORMAT declarations can be used in READ and WRITE statements to format, respectively, the input and output data.
Define identifiers, remarks, and formal symbols of parametric defines cannot be used in formats.
A format identifier can be referenced in a READ statement, WRITE statement, or SWITCH FORMAT declaration. In general, a list is referenced in READ and WRITE statements to indicate a series of data items, specified by the list, along with the formatting action, specified by the format, to be performed on each of the data items.
Editing phrases in the editing specifications are separated by a comma (,), a slash (/), or a series of slashes. A slash indicates the end of a record. On input, any remaining characters in the current record are ignored when a slash is encountered in the editing specifications. On output, the construction of the current record is terminated and any subsequent output is placed in the next output record when a slash is found in the editing specifications. Multiple slashes can be used to skip several records of input or to generate several blank records on output. The final right parenthesis or right angle bracket (>) of the editing specifications also indicates the end of the current record.
A carriage control action occurs each time a slash appears in the editing specifications. If a core-to-core part is specified in the file part of a READ statement, a slash is ignored.
Example of Editing Specifications
BEGIN
FILE READER (KIND=READER),
LINE (KIND=PRINTER);
REAL A,B;
FORMAT FMT(I2,/,I2);
READ(READER,FMT,A,B);
WRITE(LINE,FMT,A,B);
WRITE(LINE [SKIP 1],FMT,A,B);
END.Assume that the following two input records are used:
1234 5678
Using these two input records, this program produces the following output:
12 56 12 . . . [skip to channel 1] 56
If all editing specifications have been used before the list of data items is exhausted, a carriage control action occurs, and the editing specifications are reused. If the list of data items is exhausted before all the editing specifications have been used, the I/O operation is complete and the remaining editing specifications are ignored.
Simple String Literal
The presence of a simple string literal in the editing specifications indicates that the characters enclosed in quotation marks are to be used as the data. A simple string literal does not require a corresponding list element.
To enable more efficient handling of string literals in formats, 1-bit, 2-bit, and 7-bit strings are not allowed. The lengths of 3-bit and 4-bit strings must be a multiple of 2, to facilitate packing into 6-bit or 8-bit characters, respectively.
If no string code appears in a string literal, the default character type is used. The default character type can be designated by the compiler control option ASCII. If no such compiler control option is used, the default character type is EBCDIC. For more information, refer to Default Character Type.
Example of Simple String Literal
Assume you are using the following statement:
WRITE(LINE,<4"C1C2",8"ABC">);
This statement produces the following output:
ABABC
When a simple string literal appears in editing specifications, only the first digit of the string code is used; if a second or third digit appears, a warning is given at compilation time.
Simple string literals appearing in editing specifications can be read-only or read/write, depending on the in-out part specified in the FORMAT declaration. If the in-out part is IN, simple string literals appearing in the editing specifications are read-write, and the format can be used in both READ statements and WRITE statements. When a format used in a READ statement is declared with an in-out part of IN and contains a simple string literal in the editing specifications, then data is read into the memory location of the simple string literal over the original value.
The number of characters read always equals the length of the simple string literal as it is defined in the FORMAT declaration. When the format is used in a subsequent WRITE statement, the new data is written to the output record. If the in-out part is OUT or unspecified (in which case OUT is assumed), any simple string literals appearing in the editing specifications are read-only. Any attempt to change the value of a read-only simple string literal by using that format in a READ statement results in a run-time error.
Repeat Part
The repeat part indicates the number of times an editing phrase or editing specifications are repeated. If the repeat part is unspecified, a value of 1 is assumed. A repeat part value greater than 4029 results in a syntax error.
Editing specifications and their corresponding repeat parts can be nested. For example, assume you are using the following WRITE statement:
WRITE(F,<2(2(2I3))>,INT1,INT2,INT3,INT4,INT5,INT6,INT7,INT8)
The first repeat part indicates that the editing specifications (2(2I3)) are to be repeated twice, the second repeat part indicates that the editing specifications (2I3) are to be repeated twice, and the third repeat part specifies that the editing phrase I3 is to be repeated twice, causing the editing phrase I3 to be used a total of eight times.
The following examples show the correct syntax of repeat parts:
3F10.4 3(A6/) 3(3A6,3(/I12)/)

