Re: HELP! READ TEXT FILE
- From: beliavsky@xxxxxxx
- Date: 16 Jun 2005 03:32:43 -0700
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.
.
- Follow-Ups:
- Re: HELP! READ TEXT FILE
- From: Dr Ivan D. Reid
- Re: HELP! READ TEXT FILE
- References:
- HELP! READ TEXT FILE
- From: TC
- Re: HELP! READ TEXT FILE
- From: Dr Ivan D. Reid
- HELP! READ TEXT FILE
- Prev by Date: Re: hypergeometric function
- Next by Date: Re: hypergeometric function
- Previous by thread: Re: HELP! READ TEXT FILE
- Next by thread: Re: HELP! READ TEXT FILE
- Index(es):