Re: Handling Strings / Files.


[ DelphiLand Discussion Forum ]

Posted by WAllison on December 01, 2001:

In Reply to: Handling Strings / Files. posted by GuptiRanj. on May 12, 2001:

: How would i capture all the text in a .txt to work with? I don't know how i'd go about working with the whole of the information in a .txt. EG:

: c:\Example1.txt:
: Line1 in example1.txt
: Line2 in example1.txt

: Line4 in example1.txt
: Line5 in example1.txt

: Now how would i take this information and say put it in the same format as above into another .txt, c:\example2.txt.

: this without obviously just duplicating the first .txt. Basically i'm wanting to know how to store the information in a .txt and manipulate it.

//This might help

procedure ReadTextFile;
begin
AssignFile(F, 'path+textfile');
Reset(F);
While not EOF(F) do
begin
Readln(f, s);
Listbox1.Items.add(s);
end;
CloseFile(F);
end;

procedure WriteTextFile;
var i: integer;
f:file;
begin
assignfile(f,'path+filename');
for i := listbox1.items.count -1 to 0 do
writeln(f, listbox1.items[i]);
closefile(f);
end;


[ DelphiLand Discussion Forum ]