Data Format for Free-Field Input

The use of a free-field part element in a READ statement allows input to be performed with editing but without using editing specifications. The appropriate format is selected automatically.

On input, only the simplest forms of the free-field part, a single slash (/) or double slash (//), can be used. These formats allow input from records in the form of free-field data records. A single slash indicates that data items are delimited by a comma; a double slash indicates that data items are delimited by one or more blanks.

Free-Field Data Format

The format of a free-field input data record is as follows:

  ┌◄─────────────────────────┐
──┴─┬─<field>──────────────┬─┴─────────────────────────────────────────┤
    └─<explicit delimiter>─┘

<field>

──┬─<unquoted string>────────────────┬─<field delimiter>───────────────┤
  ├─<number>────────┬─┬──────────────┤
  ├─<quoted string>─┤ └─<commentary>─┘
  ├─<hex string>────┤
  ├─ / ─────────────┤
  └─ * ─────────────┘

<unquoted string>

Any string not containing an <explicit delimiter>.

<quoted string>

── <EBCDIC string> ────────────────────────────────────────────────────┤

<hex string>

── 4" ──<hexadecimal string>── " ──────────────────────────────────────┤

<commentary>

Any string not containing an <explicit delimiter>.

<field delimiter>

──┬─<explicit delimiter>─┬─────────────────────────────────────────────┤
  └─<end-of-record>──────┘

<explicit delimiter>

Comma (,) for the single-slash form or one or more blanks for the double-slash form. An empty record is not considered an explicit delimiter.

<end-of-record>

The end of the input record.

Each record of free-field input data must be in the form described earlier.

Empty records are ignored. The commentary option is ignored.

Each field except the slash is associated with the list element to which it corresponds by position.

Fields

The single-slash format interprets a field that contains only a comma or a comma preceded by blanks as a null field. Such a field is skipped along with its associated list element, which is left unaltered.

The different types of fields are described in the following paragraphs.

Unquoted String

If an unquoted string is read into a list element of type string or pointer, all characters preceding the explicit delimiter (including quotation marks if present) are transferred to the list element. The end-of-record is not recognized as a delimiter.

If an unquoted string is read into a list element of type string, characters are read until an explicit delimiter is detected or until the maximum string length (2**5 - 2) is reached.

If an unquoted string is read into a list element of type pointer, characters are read until an explicit delimiter is detected or until the end of the array is reached.

If an unquoted string is read into a list element of type Boolean, the value TRUE is assigned to the list element if the first character of the string is T. If the first character is not the letter T, the value FALSE is assigned to the list element. The unquoted string is read until a field delimiter is detected.

If an unquoted string is read into a list element of any type other than string, pointer, or Boolean, it is treated as commentary.

Number

A number that is represented as an integer is treated as type INTEGER unless it is larger than the largest allowable integer, in which case it is treated as type DINTEGER. Numbers that contain a decimal fraction are treated as type REAL. However, when the list element is double-precision, results are treated as type DOUBLE. When the field delimiter is a comma, blanks within numbers are ignored.

Complex values are divided into real and imaginary values. When a complex variable or complex subscripted variable appears in the list of a free-field READ statement, two fields are necessary to complete the read operation. The value in the first field is assigned to the real part, and the value in the second field is assigned to the imaginary part.

Quoted String

A quoted string of any length can be read into single-precision or double-precision list elements. Each single-precision EBCDIC list element receives six characters (12 characters for double-precision list elements), until either the list or the string is exhausted. If the number of characters in the string is not a multiple of six (for EBCDIC) then the last list element receives the remaining characters of the string. The string characters are stored, right-justified, in the list elements.

Hex String

A hexadecimal string can be read into a single-precision or double-precision list element. If fewer than 12 hexadecimal digits are read into a single-precision variable (or fewer than 24 hexadecimal digits into a double-precision variable), the string is stored right-justified in the variable. If a minus sign precedes the string (for example, -4"A"), bit 46 of the resulting value is complemented.

Slash (/)

The slash field causes the remainder of the current buffer to be ignored. The buffer following the slash is considered the beginning of a new field. The slash is a field by itself and must not be placed within another field or between a field and its explicit delimiter.

Asterisk (*)

The asterisk field terminates the READ statement. The program continues with the statement following the READ statement. The list element corresponding to the asterisk remains unchanged, as do any subsequent elements in the list.

Examples of Fields

    1,
    2.5,   / anything to the right of a slash is ignored
    2.48 @ -20,  / blanks are ignored if using single-slash editing
    3 4      / two data elements if the delimiter is a blank
    3,4,     / two data elements if the delimiter is a comma
    "THIS IS A QUOTED STRING"
    THIS IS AN UNQUOTED STRING AND THE DELIMITER IS A COMMA, 123
    THIS-IS-AN-UNQUOTED-STRING-AND-THE-DELIMITER-IS-A-BLANK 456
    2.5  ANY COMMENT OR NOTE NOT CONTAINING A COMMA,
    4"AB" / A HEX STRING
    -4"40000000000A" / BIT 46 IS COMPLEMENTED, THE RESULT = +10
    ,,,  / nullfields; the three corresponding list elements are
      / skipped with no alteration to their contents.
    4,  ,5 / null field is ignored
    * THIS DATA RECORD TERMINATES THE READ STATEMENT