Всем спасибо, я сделал так:
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; TextFile: TStringList; implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin TextFile.Add(memo1.Text); end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin TextFile.SaveToFile('C:\1.txt'); end;
procedure TForm1.FormCreate(Sender: TObject); begin memo1.Clear; TextFile := TStringList.Create; if FileExists('C:\1.txt') then TextFile.LoadFromFile('C:\1.txt') else TextFile.SaveToFile('C:\1.txt'); end;
end.
|
|