Autor Beitrag
mlspider
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Do 23.10.03 21:49 
Hi,

Ich möchte in einer Textdatei meine neu zugewiesene IP gegen die alte austausen. Da es sich um mehrere hundert Dateien handelt, würde ich gern diesen Vorgang mit Delphi automatisieren.

Nun meine Frage: Geht so etwas überhaupt? Wenn ja, wäre ein kleines Beispiel nicht schlecht.

Die Dateien haben alle den selben Aufbau:

208.230.181.241//secure/MP3/Titel.wma
JustusJonas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 222



BeitragVerfasst: Fr 24.10.03 07:47 
Ich würde jede einzelne Datei in eine Suche in: Delphi-Forum, Delphi-Library STRINGLIST einlesen und dort dann mit Suche in: Delphi-Forum, Delphi-Library STRINGREPLACE den String ersetzen!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
        
var
s: TStringList

begin
 s[i] := StringReplace(s[i], alterString, neuerString, []);
end;

end.
mlspider Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Fr 24.10.03 09:38 
Entspricht "alter String" meine alte IP und neuer String meine neue IP?
Licki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 132

Knoppix, Win 95, Win 2000, Win NT, Win 98, Win XP
Delphi 3
BeitragVerfasst: Fr 24.10.03 10:21 
Ja, deine alte IP ist eben der alte String und deine neue, also die wo du einsetzen willst die neue.
mlspider Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Fr 24.10.03 10:25 
Von der Sache her schon klar, aber eine Ip kann ja eine unterschiedliche Länge haben.

Wie kann ich das bewerkstelligen, ohne das der Rest, also "das soll ersetzt werden/ab hier keine Änderungen
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19336
Erhaltene Danke: 1751

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 10.11.03 12:46 
Titel: Ist doch so!
Hallo!

Na, die Funktion ersetzt doch nur den angegebenen String!

Also, folgendes geht zum Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
//...
var a: String;
begin
  a:='Das ist Ip 100.100.10.1, also ziemlich lang!';
  a:=StringReplace(a, '100.100.10.1''1.1.1.1', []);
  //Jetzt ist a='Das ist Ip 1.1.1.1, also ziemlich lang!'
  a:=StringReplace(a, '1.1.1.1''100.100.10.1', []);
  //Jetzt ist a wieder der ursprüngliche String:
  //a='Das ist Ip 100.100.10.1, also ziemlich lang!'
end;


Na ja, und a kannst Du dir wieder als a[i] einer StringList oder ähnliches denken...

Es wird also automatisch ein String beliebiger Länge durch einen anderen einer beliebigen (auch anderen) Länge ersetzt!

Hoffe, jetzt ist das klar!

Schönen Gruß,
S.J.