Changing Textfiles

Please discuss general Delphi programming topics here.

Changing Textfiles

Postby melted.marsbar » October 10th, 2007, 10:12 am

Hey guys, my first post! I'm doing Delphi programming at school at the moment - I'm pretty good, but I do have a couple of questions from time to time. So I thank you in advance for your assistance.

First one for today :)

How do I change the data in textfiles? I know how to add data to it and completely clear it, but how to I write over the text on a line? Say I have this text file:

Code: Select all
John Smith
100
200
300


How do I change "200" to say "400"?

Thanks! melted.marsbar
melted.marsbar
Member
Member
 
Posts: 2
Joined: October 10th, 2007, 10:05 am

Postby Kambiz » October 10th, 2007, 3:20 pm

As a text file, you have to read the entire file, change the line you want, and write the entire data back to file.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby melted.marsbar » October 11th, 2007, 11:07 am

Ah okay. Well in that case, I shall use an array =) Thanks!
melted.marsbar
Member
Member
 
Posts: 2
Joined: October 10th, 2007, 10:05 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 12 guests

cron