Edit-Directed Output

The EDIT option specifies edit-directed output.

The PUT EDIT statement uses a format list to control the position of the output stream and the conversion of the values specified by the output list. Each output value is converted under control of a data format, and the resulting characters are written to the output stream.

When multiple (output-list) (format-list) pairs are specified, this is equivalent to specifying all the output items consecutively in one list, then all the format items consecutively in one list.

For a description of each data format conversion, see the section Format Controlled Conversion in the chapter Data Type Conversions, and for a description of format list evaluation, see the section FORMAT Statement.

PUT FILE(F) EDIT(A,B,C) (E(14,3),SKIP,F(10)); 
PUT FILE(F) EDIT(D) (A);

In this example, A is converted under control of E (14,3), and 14 characters are written to the output stream, a new line is begun by SKIP, B is converted under control of F (10), and 10 characters are written to the output stream, C is then converted under control of E (14,3) and written to the output stream. The SKIP is not evaluated a second time because no more values remain to be output from the output list. The second statement converts D to a character string whose length is determined by the normal rules for conversion to character string. For further information on conversions, see the chapter Data Type Conversions. The resulting value is written to the same line as C, unless C happened to just fill a line. In that case, D begins on the next line.

If the original output value is a character string or a pictured value, and the file control block does not have the PRINT attribute, each contained quotation mark is replaced by two quotation marks and the entire string is enclosed by quotation marks.

The possibly modified character string is placed into the output stream followed by a single blank. If the file control block has the PRINT attribute and LINESIZE 20, for example, the value is followed by sufficient blanks to ensure that the next output begins in the next tab stop. At least one blank always separates fields.

If a character string does not fit on a line, a new line is begun and the string is written on that line and subsequent lines, if necessary.

PUT FILE(F) LIST(52,1.07E+5); 
PUT FILE(F) LIST('ABCX');

would produce (assuming a line size of 20): boxes

boxes

In this example, the value 52 converts to boxes52 and is output followed by a single blank, 1.07E+5 converts to box1.07E+05 and is followed by a single blank, and 'ABCX ' converts to ABCX. The resulting value does not fit on a line of size 20, so it is written on the next line followed by a blank. If the file control block had the PRINT attribute, the last value would be output without quotation marks and each value would be followed by sufficient blanks to ensure that the next value would begin at the next tab stop.

If the PRINT attribute does not exist, the output would look like this:

boxes