PieterJ
asked on
Textfile
Hi guys,
Say for instance I have 3 .rtf files, how can I actually add/append them together (So that I only have one file) before doing any work on it ?
Here is the Code I use for one, but somewhere in between I have to append 3 different .rtf files :
procedure TForm1.Button1Click(Sender : TObject);
var
F : TextFile;
aString : String;
begin
aString := ExtractFileDir(ParamStr(0) ) + '\Test.rtf';
AssignFile(F, aString);
Reset(F);
while not EOF(F) do
begin
Readln(F, bString);
// Do whatever
end;
CloseFile(F);
end;
Thanks
Pieter
Say for instance I have 3 .rtf files, how can I actually add/append them together (So that I only have one file) before doing any work on it ?
Here is the Code I use for one, but somewhere in between I have to append 3 different .rtf files :
procedure TForm1.Button1Click(Sender
var
F : TextFile;
aString : String;
begin
aString := ExtractFileDir(ParamStr(0)
AssignFile(F, aString);
Reset(F);
while not EOF(F) do
begin
Readln(F, bString);
// Do whatever
end;
CloseFile(F);
end;
Thanks
Pieter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HI,
When reading the comments above I seem to find myself in Turbo Pascal 7.0 again. It's very pleasant remembrances but why don't use TFileStream or TMemoryStream technique?
Sincerely,
Nestorua.
When reading the comments above I seem to find myself in Turbo Pascal 7.0 again. It's very pleasant remembrances but why don't use TFileStream or TMemoryStream technique?
Sincerely,
Nestorua.
Then open the other 2 files with Reset(f) and in your While Not EOF(f) loop, add each line to File 1. i.e.
procedure TForm1.Button1Click(Sender
var
F, F2 : TextFile;
aString, bString : String;
begin
aString := ExtractFileDir(ParamStr(0)
AssignFile(F, aString);
Append(F);
aString := ExtractFileDir(ParamStr(0)
AssignFile(F2, aString);
Reset(F2);
while not EOF(F2) do
begin
Readln(F2, bString);
Writeln(F, bString);
end;
CloseFile(F2);
CloseFile(F);
end;
J.