Louis Krupp
2004-10-05 18:34:08 UTC
I am using Microsoft Fortran 4.0 (yes, I know its old, but we have a lot of
apps
written for it here at work) in a PC environment. I have the need to scan a
text file consisting of
from 1 to 80 characters per line (terminated by a cr/lf) looking for certain
character.
I am have trouble trying to figure out how to read one character at a time.
===============================================================
C Test of MicroSoft Fortran 4.0
C
PROGRAM TESTRD
CHARACTER C
WRITE(*,100)
100 FORMAT(' ** Test to read one character at a time **'//)
OPEN(10,FILE='TESTFIL.ASC')
105 READ(10,110,END=999) C
110 FORMAT(A1)
WRITE(10,120) C
120 FORMAT(1X,A1,$)
GOTO 105
999 CLOSE(10)
END
==============================================================
==============================================================
**Test to read one character at a time **
1 1 1 1 1 1 1 1
==============================================================
==============================================================
1N34
To <------)||(------>|----+-----o+
Spkr 8ohm )||( 200ohm |+ to
jack <------)||(---+ === 1uf strip chart
| | recorder
+--------+-----o -
<snip>apps
written for it here at work) in a PC environment. I have the need to scan a
text file consisting of
from 1 to 80 characters per line (terminated by a cr/lf) looking for certain
character.
I am have trouble trying to figure out how to read one character at a time.
===============================================================
C Test of MicroSoft Fortran 4.0
C
PROGRAM TESTRD
CHARACTER C
WRITE(*,100)
100 FORMAT(' ** Test to read one character at a time **'//)
OPEN(10,FILE='TESTFIL.ASC')
105 READ(10,110,END=999) C
110 FORMAT(A1)
WRITE(10,120) C
120 FORMAT(1X,A1,$)
GOTO 105
999 CLOSE(10)
END
==============================================================
==============================================================
**Test to read one character at a time **
1 1 1 1 1 1 1 1
==============================================================
==============================================================
1N34
To <------)||(------>|----+-----o+
Spkr 8ohm )||( 200ohm |+ to
jack <------)||(---+ === 1uf strip chart
| | recorder
+--------+-----o -
[and it goes on for several kilobytes]
===============================================================
Your program reads and writes unit 10. Are you sure you want to do===============================================================
that? I wouldn't have expected any output at all after the ' ** Test' line.
You might want to read an array of 80 characters for each line of the
file and then loop through the array looking for the character of
interest. Someone else will have a better handle on how to tell how
many characters you've read (or that might be in your manual).
Louis Krupp