Autor Beitrag
sCrAPt
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 01:45 
Hi

Hmm mir wurde gesagt ich soll da ein neues Thema beginnen also mache ich das auch.....

Wie kann ich den einen text in einer TXT ersetzten ohne ihn in ein memo laden zu müssen?


Ciao
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 03.02.03 02:38 
Hi,

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TXTReplace(Old, New: String);
var
  ts: TStringList;
begin
  ts:=TStringList.Create;
  ts.LoadFromFile('Bla.txt');
  ts.Text:=StringReplace(ts.Text,Old,New,[rfReplaceAll,rfIgnoreCase]);
  ts.SaveToFile('Bla.txt');
  ts.Free;
end;


Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 09:22 
Besser:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TXTReplace(Old, New: String); 
var 
  ts: TStringList; 
begin 
  ts:=TStringList.Create; 
  try
    ts.LoadFromFile('Bla.txt'); 
    ts.Text:=StringReplace(ts.Text,Old,New,[rfReplaceAll,rfIgnoreCase]); 
    ts.SaveToFile('Bla.txt'); 
  finally
    ts.Free; 
  end;
end;
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 03.02.03 14:38 
Perfekt:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TXTReplace(FileName, Old, New: String); 
var 
  ts: TStringList; 
begin 
  ts:=TStringList.Create; 
  if FileExists(FileName) then begin
    ts.LoadFromFile(FileName); 
    ts.Text:=StringReplace(ts.Text,Old,New,[rfReplaceAll,rfIgnoreCase]); 
    ts.SaveToFile(FileName); 
  end;
  ts.Free; 
end;


*winkt*
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 14:40 
Du hast den Ressoucenschutzblock schon wieder vergessen. :wink:
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 03.02.03 14:41 
Resourcenschutzblock...???

_________________
Aya
I aim for my endless dreams and I know they will come true!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 14:47 
Siehe mein Posting: try-finally-end.
sCrAPt
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 14:58 
Es geht wieder nicht :evil: Es kommen am schluss wieder nur ein paar Zeichen!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 15:00 
Ist es denn eine reine Text-Datei (ASCII)?
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 03.02.03 15:03 
sCrAPt: Schick mir die Datei mal... :) -> Aya@Koshigaya.de

_________________
Aya
I aim for my endless dreams and I know they will come true!
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mo 03.02.03 15:19 
ähm...

Auf den ersten Blick würde ich sagen das die Datei Binär geschrieben wurde.. also kein ASCII...

= du kannst so garnix von lesen :)
Ausser du weißt wo was steht etc.

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 16:07 
Für alle neugierigen unter euch: Es hat sich um ein Word-Dokument gehandelt, dessen Endung in txt geändert wurde in der Hoffnung sie dann in ein Memo laden zu können.
sCrAPt
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 03.02.03 16:16 
Du Verräter :P
Einen Versuch war es doch wert....
Ist die Frage beantwortet? Das Problem gelöst?

Dann klicke hier, um das Thema entsprechend zu markieren!