The formatted internal READ statement performs the following operations:
The formatted internal READ statement behaves as if the format begins with a BN edit descriptor. You can override this behavior by explicitly specifying the BZ edit descriptor.
The following program segment reads a record and examines the first character to determine whether the remaining data should be interpreted as decimal, octal, or hexadecimal. It then uses internal-file reads to make appropriate conversions from character string representations to binary.
INTEGER IVAL CHARACTER TYPE, RECORD*80 CHARACTER*(*) AFMT, IFMT, OFMT, ZFMT PARAMETER (AFMT='(Q,A)', IFMT= '(I10)', OFMT= '(O11)', 1 ZFMT= '(Z8)') ACCEPT AFMT, ILEN, RECORD TYPE = RECORD(1:1) IF (TYPE .EQ. 'D') THEN READ (RECORD(2:MIN(ILEN, 11)), IFMT) IVAL ELSE IF (TYPE .EQ. 'O') THEN READ (RECORD(2:MIN(ILEN, 12)), OFMT) IVAL ELSE IF (TYPE .EQ. 'X') THEN READ (RECORD(2:MIN(ILEN, 9)),ZFMT) IVAL ELSE PRINT *, 'ERROR' END IF END