Autor Beitrag
JiimmyC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP SP1

BeitragVerfasst: Di 06.05.08 15:02 
Wie koennte man dies tun ohne es in ein Memo zu lesen?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Form1.Memo1.Lines.LoadFromFile('d:\test.txt');
source:=Form1.Memo1.Text;
position:=Pos(GesuchteLine,source);
position:=position + Length(GesuchteLine);
while source[position] <> ' ' do begin
      Delete(source,position,1);
end;
Insert('CHANGE',source,position);
Form1.Memo1.Text:= source;
Form1.Memo1.Lines.SaveToFile(d:\test.txt);


Ich habe ein paar Seiten durchgelesen doch vertehe ich vieles nicht. Ich komme aus der Win32 Api Welt und bin es gewohnt eine File in ein Buffer zu lesen und von dort aus alles zu machen. Der Umweg ueber das Memo funktioniert doch scheint es mir etwas doof. :-/


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Di 06.05.2008 um 15:10

_________________
Information in this online help system is subject to change without notice.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 06.05.08 15:31 
Moin!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  var
    SL: TStringList;
    Position: Integer;
begin
  SL := TStringList.Create;
  try
    SL.LoadFromFile('d:\test.txt');
    Position := SL.IndexOf(GesuchteZeile);
    if (i >= 0then begin
      ShowMessage(SL.Strings[Position]);
      // Dinge tun...
      SL.SaveToFile('d:\test.txt');
    end
    else
      ShowMessage('Zeile nicht gefunden!?');
  finally
    SL.Free;
  end;
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Di 06.05.08 15:43 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  var
    SL: TStringList;
    Position: Integer;
begin
  SL := TStringList.Create;
  try
    SL.LoadFromFile('d:\test.txt');
    Position := SL.IndexOf(GesuchteZeile);
    if (Position >= 0then begin
      ShowMessage(SL.Strings[Position]);
      // Dinge tun...
      SL.SaveToFile('d:\test.txt');
    end
    else
      ShowMessage('Zeile nicht gefunden!?');
  finally
    SL.Free;
  end;

;)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 06.05.08 15:53 
:oops:

_________________
There are 10 types of people - those who understand binary and those who don´t.
JiimmyC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP SP1

BeitragVerfasst: Mi 07.05.08 17:45 
Danke recht herzlich. Musste SL.IndexOfName benutzen das mir irgendwie limitiert erscheint. Doch ging es mit etwas muehe.

_________________
Information in this online help system is subject to change without notice.