On Apr 23, 12:54=A0pm, elijah <mily...@[EMAIL PROTECTED]
> wrote:
> > So you want to replace the contents in print positions 11 to 20 with
> > something else? Again, you want to over-write the old data with the
> > new, leaving the length of the original line unchanged?
>
> yes that's what I want to do
Try something like this:
implicit none
character*200 s
integer ierr, n
n=3D0
open(10,file=3D'file.txt')
open(11,file=3D'file1.txt')
do
read(10,'(a)',iostat=3Dierr) s
if (ierr /=3D 0) exit
n=3Dn+1
if (n =3D=3D 178) s(11:20) =3D '1234567890'
write(11,'(a)') trim(s)
end do
close(10)
close(11)
end
-------------
1. This is free format source code. Other features are
1a. Exit exits the DO ... END DO loop
1b. One line IF
1c. DO .. END DO loop - no index variable
2. Several "magic" numbers & constants in program - adjust as needed.
-- 200 =3D maximum length of input line
-- 178 =3D target line to change
-- 11 =3D first print column to change
-- 20 =3D last print column to change
-- string literal =3D replace part of target with this
-- input and output file names
3. On input, lines are padded at the end with spaces up to 200
characters.
4. On output trim() removes trailing spaces, otherwise the output
would be 200 characters wide (+ end of line).
5. One possible GOTCHA - make sure that the replacement string is
exactly 10 characters long.
Fortran does not read or write variable length strings as does BASIC.
In BASIC, the length of a string depends on what is input.
Since your input lines are variable length, the program tries to
prserve this by assuming that the input file does not contain trailing
spaces.
HTH
-- e


|