Re: HELP! READ TEXT FILE





Dr Ivan D. Reid wrote:
> On Thu, 16 Jun 2005 07:07:51 GMT, TC <tecomeco@xxxxxxxxx>
> wrote in <bz9se.5501$yM4.84630@xxxxxxxxxxxxxxxxxx>:
> > Hi,
> > I must read a text file char by char for make the word.
> > How make it?
>
> Read the file a line at a time into a large character variable,
> then parse the variable a character at a time, e.g.
>
> character(512) :: inline
> integer :: i,len,ifile
> character(1) :: a
>
> ... !open file, set up a loop to read the lines, etc., etc.
>
> read(ifile,'(a512)')inline !get a single line
> len=len_trim(inline) !find the last non-blank character
> do i=1,len !loop through the line
> a=inline(i:i) !using individual characters
> ... !process character
> enddo

I think the READ format '(a512)' can be replaced with the simpler
'(a)', giving the same results.

.