Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
Turbo Delphi für Win32
|
Re: Ausgabe in Datei
29. Jul 2006, 15:49
Und um es jedesmal zu speichern musst du dir schon selber ne Klasse basteln. Sowas zum Beispiel:
Delphi-Quellcode:
type
TLog = class
protected
FFileName: String;
procedure SetFileName(FileName: String);
public
constructor Create(FileName: String);
procedure Write(Text: String);
property FileName: String read FFileName write SetFileName;
end;
...
implementation
constructor TLog.Create(FileName: String);
begin
inherited Create;
Self.FileName:=FileName;
end;
procedure TLog.SetFileName(FileName: String);
var f: TextFile;
begin
FFileName:=FileName;
assignfile(f, FFileName);
if not fileexists(FFileName) then
rewrite(f);
closefile(f);
end;
procedure TLog.Write(Text: String);
var f: TextFile;
begin
assignfile(f, FFileName);
append(f);
writeln(f, Text);
closefile(f);
end;
Manuel Eberl „The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
|