Describes how I/O data is to be formatted.
Syntax
label FORMAT (format-list) |
- label
is a statement label.
- format-list
is a comma-separated list of format items, where
each item in the list can be either one of the edit descriptors
described in Table 9-1 “Edit descriptors” or (format-list).
If format-list is a list item, it may
be optionally preceded by a repeat specification—a positive
integer that specifies how may times format-list
is to be repeated.
Description
The FORMAT
statement holds the format specification that indicates how data
in formatted I/O is to be translated between internal (binary)
representation and formatted (ASCII) representation. The translation
makes it possible to represent data in a humanly readable format.
Although a format specification can be embedded within a data
transfer statement, the point to using a FORMAT
statement is to make it available to any number of data transfer
statements. Several data transfer statements can use the same format
specification contained in a FORMAT
statement by referencing label.
Another advantage of the FORMAT
statement over the use of embedded format specifications is that
it is "pre-compiled", reducing the runtime overhead
of processing the format specification and providing compile-time
error checking of the FMT=
specifier.
Examples
PROGRAM format_example WRITE (15,FMT=20) 1234, 45, -12 20 FORMAT (I6, 2I4) END PROGRAM format_example |
When compiled and executed, this program outputs the following
(where b
represents the blank character):
Related statements
READ and
WRITE
Related concepts
For information about I/O formatting, see Chapter 9 “I/O formatting”.