cybermilky
asked on
Copy text from memo into text file
How to copy out all the text from a memo into a text file?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Memo1.Lines.SaveToFile( ... );
The easy way is to do:
memo1.lines.savetofile('Yo urFileName Here.txt') ;
If you want to do it the hard way you would have to do;
procedure Write;
var
F1 : TextFile;
i : Integer;
const
FILENAME : string = 'C:\somefile.txt';
begin
AssignFile(F1,FILENAME);
Rewrite(F1);
for i := 0 to memo1.lines.count-2 do begin
writeLn(F1,memo1.lines.str ings[i]);
end;
write(F1,memo1.lines.strin gs[i]);
CloseFile(F1);
end;
And you just call this procedure when you need to write the text to a file. I would use the easy way unless you are saving any header or footer information.
memo1.lines.savetofile('Yo
If you want to do it the hard way you would have to do;
procedure Write;
var
F1 : TextFile;
i : Integer;
const
FILENAME : string = 'C:\somefile.txt';
begin
AssignFile(F1,FILENAME);
Rewrite(F1);
for i := 0 to memo1.lines.count-2 do begin
writeLn(F1,memo1.lines.str
end;
write(F1,memo1.lines.strin
CloseFile(F1);
end;
And you just call this procedure when you need to write the text to a file. I would use the easy way unless you are saving any header or footer information.