Autor Beitrag
joerg68
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 116

Win 2000
D5Enterprise
BeitragVerfasst: Do 30.10.03 13:31 
Ich will einen String in dem verschiedene Werte durch ein Trennzeichen getrennt sind in eine TStringLIst einlesen.
Kann mir jemand helfen
Danke
Gruß

Jörg

_________________
Aus den Chaos sprach eine Stimme " Lächele und sei froh denn es könnte schlimmer kommen". Und ich lächelte und ich war froh.
UND ES KAM SCHLIMMER
Killi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Do 30.10.03 14:56 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
// Dein string samt trennzeichen (-)
name:= "Hans-jürgen-von-der-Lippe";
repeat
    // Position der 
    a:= Pos('-', name);
    // Trennen
    Stringlist.Add(Copy(name, 0, a - 2));
    name:= Copy(name, a + 1, Length(name));
until a = -1;


nicht getestet, ber müsste gehen!
joerg68 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 116

Win 2000
D5Enterprise
BeitragVerfasst: Do 30.10.03 15:01 
Habe es jetzt selbst rausgefunden. :D Hier meine Lösung
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Var Argumente : string
      Trennzeichen : integer;
// Argumente in StringList
     Argumente:= MAP.FieldByName('Argumente').asstring;
      while pos(';',Argumente)<>0 do
       begin
         Trennzeichen := Pos(';',Argumente);
         ArgLIst.Add(Copy(Argumente,0,Trennzeichen));
         Delete(Argumente,0,Trennzeichen+1);
       end;

Das mit dem Delete muß sein weil pos immer nur die erste Position liefert an der der Suchstring auftritt.


Trotzdem Danke

Gruß
Jörg

_________________
Aus den Chaos sprach eine Stimme " Lächele und sei froh denn es könnte schlimmer kommen". Und ich lächelte und ich war froh.
UND ES KAM SCHLIMMER
Killi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Do 30.10.03 15:02 
sorry, hat nicht getan, hier nochma:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure TForm1.Button1Click(Sender: TObject);
var
   a: integer;
   name: string;
   fertig: boolean;
begin
// Dein string samt trennzeichen (-)
name:= 'Hans-jürgen-von-der-Lippe';
repeat
    // Position der
    a:= Pos('-', name);
    // Trennen
    if (a > 0) then
    begin
         ListBox1.Items.add(Copy(name, 0, a - 1));
    end
    else
    begin
         ListBox1.Items.add(name);
         fertig:= True;
    end;
    name:= Copy(name, a + 1, Length(name));
until fertig = True;
end;
Killi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Do 30.10.03 15:05 
while pos <> 0 stimmt aber nicht, jedenfalls hats bei mir nicht geklappt, is ja auch klar - wenn dasTrennzeichen nicht mehr gefunden wird steht der REST noch da - bei mir "Lippe"...also evtl. danach nochmal den Rest einfügen!
joerg68 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 116

Win 2000
D5Enterprise
BeitragVerfasst: Do 30.10.03 15:26 
Im prinzip hast Du Recht aber ich sorge dafür, daß zum Schluß noch mal ein Trennzeichen steht.Dann klappt es auch mit pos(....) <> 0.
Gruß
Jörg

_________________
Aus den Chaos sprach eine Stimme " Lächele und sei froh denn es könnte schlimmer kommen". Und ich lächelte und ich war froh.
UND ES KAM SCHLIMMER
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Do 30.10.03 15:31 
Wie wärs wenn du 'delimiter'-fähigkeiten von TStringList benutzt? :

ausblenden Delphi-Quelltext
1:
2:
3:
   
  ArgLIst.delimter := ';' ; // delimiter setzen
  ArgList.DelimitedText := MAP.FieldByName('Argumente').asstring; // kommaText zuweisen


habs nicht getestet, wäre aber die einfachste möglichkeit :wink:

cu,

_________________
mfg.
mâximôv
focus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 187

XP, 2k, 98, Me
D6 Prof
BeitragVerfasst: Do 30.10.03 16:15 
www.delphi-forum.de/...18072&highlight=
zwar ein Memo aber sollte kein Problem darstellen das zu übertragen...
Gruss
Michael
joerg68 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 116

Win 2000
D5Enterprise
BeitragVerfasst: Do 30.10.03 17:14 
Delimter Kennt er bei mir nicht. Kann aber auch sein, das er das nur in D5 nicht kennt.
Gruß
Jörg

_________________
Aus den Chaos sprach eine Stimme " Lächele und sei froh denn es könnte schlimmer kommen". Und ich lächelte und ich war froh.
UND ES KAM SCHLIMMER
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Do 30.10.03 18:33 
verdammte axt :? ...immer diese versionen! Schade für dich, weil das super praktisch wär.

_________________
mfg.
mâximôv
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 31.10.03 11:03 
aber die Stringlist in D5 kann die eigenschaft commatext !! schau die dir mal in der Hilfe an !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.