Autor Beitrag
Bomania
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 139

Win XP

BeitragVerfasst: Sa 15.02.03 17:48 
Hallo,

ich lese Text aus einer Textdatei folgendermaßen aus:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button2Click(Sender: TObject);
var
  str1 : TStringlist;
  strings: String;

begin
  str1 := TStringlist.Create;
  str1.Loadfromfile('c:\demo.txt');
  strings := str1.text;
  str1.free;
  mem_Text.Text := strings;
end;


Ist diese Methode gut so, oder kann man das noch anders/besser machen?

Gruß,
Bo
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 15.02.03 17:57 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button2Click(Sender: TObject); 
var 
  str1 : TStringlist; 
  strings: String; 

begin 
  str1 := TStringlist.Create; 
  try
    str1.Loadfromfile('c:\demo.txt'); 
    strings := str1.text; 
  finally
    str1.free; 
  end;
  mem_Text.Text := strings; 
end;
Bomania Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 139

Win XP

BeitragVerfasst: Sa 15.02.03 18:28 
Vielen Dank :D
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 15.02.03 18:31 
Du könntest die Variable noch einsparen.