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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to overwrite info in a txt file open by FOPEN

Status
Not open for further replies.

richrichrich

Programmer
Sep 9, 2004
13
US
I like to overwrite certain string in a text file. For example, replace '123AAA' with '123BBB'.

Please advice and thaanks in advance.
 
Hi richrichrich,

See the help for FILETOSTR(), STRTOFILE(), STRTRAN() and CHRTRAN().

Regards,

Mike
 
You can also use FSEEK() and FWRITE()... once you FSEEK to a location in the middle of the file, FWRITE writes over whatever is there. I believe there are flags that must be set to avoid truncating the file at the end of the FWRITE output.

Depending on the size of the file, this may be much faster than FILETOSTR...etc... and if the file might ever grow bigger than 16MB, you cannot use FileToStr on files that big.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top