Thema: Delphi Problem mit Pos()

Einzelnen Beitrag anzeigen

sharkx

Registriert seit: 24. Feb 2003
Ort: St. Ingbert
211 Beiträge
 
Delphi 7 Enterprise
 
#1

Problem mit Pos()

  Alt 16. Nov 2003, 21:59
Hallo,

Folgender String möchte ich in 2 einzelteile zerlegen. Einmal den Command und einmal (ich nenns mal) Ausführung.

Der String sieht wie folgt aus:
Zitat:
.add sharkx
Lösen tu ich es mit folgendem Code
Delphi-Quellcode:
  { Content auf Command Parsen }
  CommandPos := Pos(Content, ' ');
  Commands := Copy(Content, 0, CommandPos +4);
  Memo1.Lines.Add('Parse Commands: ' + Commands);

  { Content auf Ausführung Parsen }
  TextPos := Pos(Content, ' ');
  Text := Copy(Content, 6, TextPos +Length(content));
  Memo1.Lines.Add('Parse Text: ' + Text);
Nun .. jetzt ist es aber nunmal so, das ich nicht weiß wielange der Command ist. ( .add 4, .stats 6 und so weiter )
Und was ist wenn der String am Anfang nen leerzeichen hat? Wie sollte ich dies am besten bewältigen?

Ich hoffe ich hab mich verständlich ausgedrückt :-)
Programming today is a race between Software Engineers striving to build bigger and better idiot-proof Programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning!
  Mit Zitat antworten Zitat