• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

Copy text from memo into text file

How to copy out all the text from a memo into a text file?
0
cybermilky
Asked:
cybermilky
1 Solution
 
kretzschmarCommented:
memo1.lines.savetofile('YourFileNameHere.txt');
0
 
MikProgCommented:
Memo1.Lines.SaveToFile( ... );
0
 
meadorjCommented:
The easy way is to do:
  memo1.lines.savetofile('YourFileNameHere.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.strings[i]);
  end;
  write(F1,memo1.lines.strings[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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now