The Artima Developer Community
Sponsored Link

Design Forum
Text File - Noob Question

1 reply on 1 page. Most recent reply: May 3, 2005 10:57 AM by David

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
David

Posts: 2
Nickname: ignoranus
Registered: May, 2005

Text File - Noob Question Posted: May 3, 2005 10:54 AM
Reply to this message Reply
Advertisement
Hi,

All I need to do is copy a file from one location to another and back again every hour.

What I would like to do is open a text file into a memo box and then save the contents of the memo box into a separate file. Then every hour i want the same to happen again (to update the file) but then save it back to the original file.

My solution so far:

if FileExists('D:\games\RedFaction\banlist.txt') then begin
AssignFile(F, 'D:\games\RedFaction\banlist.txt');
Reset(F);
ReadLn(F, S);
Memo1.Lines.Add(S);
end
else
ShowMessage('File C:\Hello.txt not found');
end;
end.

As you can probably see this adds only one line of the file to my memo box. This is no good. I need the whole file added so it can then be saved.

Also the file will constantly grow in lines so the app. has to be able to cope with this. My method would involve have allot of ReadLn(F, S); Memo1.Lines.Add(S); extra in the code to ensure that no lines are missed. Its a really bad solution but the only one i can think of.

pseudo
ensure file is there
load file into a variable
write variable to a memo box
save contents of memo box to an alternate location
read file from the alternate location into a variable
write variable to a memo box
save contents of memo box to the original location


anyone think they can help?


David

Posts: 2
Nickname: ignoranus
Registered: May, 2005

Re: Text File - Noob Question Posted: May 3, 2005 10:57 AM
Reply to this message Reply
I get the feeling i posted this in the wrong section.

Alos this is Delphi code :)

Flat View: This topic has 1 reply on 1 page
Topic: Agora Plastic 2005 Released !! Previous Topic   Next Topic Topic: Training Materials - O/R Mapping - from Object Model to Data Model

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use