Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy text within file

Status
Not open for further replies.

dommidom

Programmer
Apr 20, 2010
1
DE
Hi,

I am quite new to FORTRAN and programming in general and have this 'problem'.

I´ve got a program, which asks the user to enter specific input parameters for a model which are written into an input file. Now these input parameters are supposed to be copied and added at the bottom of the input file with just one parameter changing.

Anybody know how I can copy a whole text block and add it again at the end with one part changed?

Grateful for any help!

Thx
Dominik
 
There are many ways of doing this

1) Read the entire file, change the parameters, rewrite the entire file

2) Assume all the lines are of a fixed length. Open the file as a direct access file. Seek to the position of the changed parameter and rewrite the record

3) You could use a namelist. Have a look at
The problem is when the lines increase or decrease in size. If they change size, method 1 is better. If the sizes are always the same then you can use method 2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top