A READ, with the O or Z field descriptors in the FORMAT, reads in w characters as octal or hexadecimal, respectively, and assigns the value to the corresponding member of the I/O list.
Example: Octal input, the external data field is:
654321
The first digit in the example appears in input column 1.
The program that does the input is:
READ ( *, 2 ) M 2 FORMAT ( O6 )
The above data and program result in the octal value 654321 being loaded into the variable M. Further examples are included in the following table.
Table 5-6 Sample Octal/Hex Input Values
Format |
External Field |
Internal (Octal or Hex) Value |
---|---|---|
O4 O4 O3 |
1234¤ 16234 97¤¤¤ |
1234 1623 Error: "9" not allowed |
Z5 Z5 Z4 |
A23DE¤ A23DEF 95.AF2 |
A23DE A23DE Error: "." not allowed |
The general rules for octal and hex input are:
For octal values, the external field can contain only numerals 0 through 7.
For hexadecimal values, the external field can contain only numerals 0 through 9 and the letters A through F or a through f.
Signs, decimal points, and exponent fields are not allowed.
All-blank fields are treated as having a value of zero.
If a data item is too big for the corresponding variable, an error message is displayed.