Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Problem mit Pos() (https://www.delphipraxis.net/11921-problem-mit-pos.html)

himitsu 16. Nov 2003 22:50

Re: Problem mit Pos()
 
@Minz

Aus der OH:
Zitat:

function Copy(S; Index, Count: Integer): string;

Gibt Count mehr Zeichen oder Array-Elemente an, als verfügbar sind, werden nur die Zeichen oder Elemente von S[Index] bis zum Ende von S zurückgegeben.

sharkx 16. Nov 2003 22:51

Re: Problem mit Pos()
 
hmm, eben doch nicht ...

ich geb mal nen paar Content Strings mit an und deren Ergebniss nach dem Parsen
Delphi-Quellcode:

sharkx: .help
        ^-------------------- Das ist der String Content, daraus wurde ...
Parse Commands:
Parse Text: .help

sharkx: .stats
Parse Commands:
Parse Text: .stats

sharkx: .add noob
Parse Commands: .add
Parse Text: noob
^---------------------------- So ist es richtig
Delphi-Quellcode:
 
  TextPos    := Pos(' ', Content);
  Text       := Trim(Copy(Content, CommandPos+1, length(Content)-CommandPos));

  CommandPos := Pos(' ', Content);
  Commands   := Trim(Copy(Content, 1, CommandPos-1));


[EDIT]

*Kopfklatsch*
Das problem ist, ich weiß nichtmal ob ich überhaupt ein Leerzeichen übergeben bekomme! Also kann ich ja auch nicht immer danach suchen. Selbst dieser Punkt ist bicht immer da (.add). Also hab ich praktisch überhaupt keinen ansatz nachdem ich suchen könnte :/

scp 16. Nov 2003 22:54

Re: Problem mit Pos()
 
Zitat:

Zitat von Minz
weil du gibst ja die Länge an, die gelesen werden soll
daher darfs nicht length(content) sein! sonst versuchst du
ab dem Trennzeichen die ganze Länge von Content zu kopieren.

Zitat:

Zitat von Delphi-Hilfe
Gibt Count mehr Zeichen oder Array-Elemente an, als verfügbar sind, werden nur die Zeichen oder Elemente von S[Index] bis zum Ende von S zurückgegeben.


himitsu 16. Nov 2003 23:00

Re: Problem mit Pos()
 
Also nach diesem Aufbau?

Name: .Commands Text
Name: Commands Text

Name:.Commands Text
Name:Commands Text

Name: .Commands
Name: Commands

Name:.Commands
Name:Commands

scp 16. Nov 2003 23:01

Re: Problem mit Pos()
 
Dann musst du halt If verwenden:

Delphi-Quellcode:
If (Pos(' ', Content) > 0) then
  begin
    // Normaler Code
  end
else
  begin
    Command := Content;
    Text := '';
  end;

sharkx 16. Nov 2003 23:02

Re: Problem mit Pos()
 
endlich .. schwere geburt .. vielen dank :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:37 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz