Autor Beitrag
smepal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

Win XP, Linux Mandbrake,SUSE 10.1, SUSE 9 PE, DEBIAN, Win 2000 Pro, Win XP Pro
Delphi
BeitragVerfasst: Mi 28.12.05 22:57 
habe folgendes Problem:

Ich habe ein Server und ein Clientsocket, welche sic Infos hin und her schicken. Dabei müssen mehrere Infos in Form von Ziffern auf ein mal also in eine clientsocket.sendtext verpackt werden. Das is ja kein Problem, aber wie kann ich den server den String wieder in die einzelnen Ziffern zerlegen lassen???
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 28.12.05 23:06 
Suchst du String[i]?

In einer for-schleife dürfte das kein problem sein..

greetz

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
smepal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

Win XP, Linux Mandbrake,SUSE 10.1, SUSE 9 PE, DEBIAN, Win 2000 Pro, Win XP Pro
Delphi
BeitragVerfasst: Mi 28.12.05 23:12 
ich möchte mehrere infos in einen string zb so 1:2:3:4:234:23
und dann eine procedure die mir die werte wieder zurückgibt also:
1
2
3
4
234
23
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 28.12.05 23:19 
user profile iconsmepal hat folgendes geschrieben:
ich möchte mehrere infos in einen string zb so 1:2:3:4:234:23
und dann eine procedure die mir die werte wieder zurückgibt also:
1
2
3
4
234
23


Kennst du die funktion pos?

ich würde es in eine while-schleife packen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
while pos(':', deinString) > 0 do
begin
  memo1.lines.add(copy(deinstring, 0, pos(':', deinString)-1));
  deinString := copy(deinString, pos(':', deinstring)+1, length(deinstring));
end;
memo1.lines.add(deinstring);


ungetestet aber sollte funkttionieren :)

greetz

EDIT: Fehler korrigiert!

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 28.12.05 23:43 
Such mal nach Suche in: Delphi-Forum, Delphi-Library EXPLODE Das sollte Dir helfen ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 28.12.05 23:54 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
 I: Integer;
begin
  with TStringList.Create do
   try
    Delimiter := ':';
    DelimitedText := 'Ich:möchte:meinen:String:zerlegt:haben';
    for I := 0 to Count-1 do
     ShowMessage(Strings[I]);
   finally
    Free;
   end;
end;
smepal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

Win XP, Linux Mandbrake,SUSE 10.1, SUSE 9 PE, DEBIAN, Win 2000 Pro, Win XP Pro
Delphi
BeitragVerfasst: Do 29.12.05 11:44 
Vielen Dank funktioniert!!!