Autor Beitrag
JiimmyC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP SP1

BeitragVerfasst: Di 22.04.08 13:02 
Ich habe ein Memo mit folgendem Beispiel Text:

ID=615&Titel=Munchkin;ID=98&Titel=House;ID=1234&Titel=Monster;etc..

Nun muss ich dies auslesen und in ein ListView setzen, ich habe dies mit Pos() und Copy() getan und mein Code sieht ungefaehr so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
const
IDTAG 'ID=';

var
position:integer;
position2:integer;
s:string;

begin
position:=Pos(IDTAG, Memo1.Text);
position2:=Pos('&', Memo1.Text);
position2:=position2-position;
s:=Copy(Memo1.Text, position+Sizeof(IDTAG), position2); // Nummer
// Adde die Nummer zur ListView


...und dann gehe ich zum Titel und kopiere dies in s, das ich wiederum zur ListView adde. (Sorry, der Code ist zu Hause und ich bin auf der Arbeit :-/.)

Meine Frage ist nun, ist dies der richtige Weg? _und_ Wie gehe ich zum naechsten ID= ueber ohne den ganzen Text nach der Nummer nach s zu kopieren und dann wiederum in Memo1.Text zu schreiben (und damit dabei den ersten zu ueberspringen?)

Danke im Voraus.

_________________
Information in this online help system is subject to change without notice.


Zuletzt bearbeitet von JiimmyC am Di 22.04.08 13:24, insgesamt 1-mal bearbeitet
Handycommander
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Di 22.04.08 13:11 
wie wärs wenn du den ganzen text an den ";" teilst und in ein array einließt? und dann beim einfügen in die listview nochmal teilst an den "&" und die führenden zeichen inkl. "=" entfernst... und schon hast du deine einträge :)

mfg tobi
JiimmyC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP SP1

BeitragVerfasst: Di 22.04.08 13:23 
Ich sehe was du meinst doch moechte ich dies nicht tun. Wie gesagt ist dies bloss ein Beispiel Text, es geht mir mehr um die Weise wie dies getan werden muesste, wenn die Daten nicht so perfekt angeordnet waeren. ;)

_________________
Information in this online help system is subject to change without notice.
Handycommander
ontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1054

Windows XP Pro, Vista
Visual Studio 2008
BeitragVerfasst: Di 22.04.08 16:23 
hmm... aber die möglichkeit ist am einfachsten ;)
wie sieht denn dein text denn wirklich aus?

mfg tobi
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Di 22.04.08 16:25 
mit posex kann man von einer bestimmten stelle an in einem string suchen. so könnest du immer den nächsten rausfiltern.

zum weg kann ich nix sagen, bin zu müde um mir code durchzulesen. sorry!

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
JiimmyC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 35

WinXP SP1

BeitragVerfasst: Mi 23.04.08 16:53 
Vielen Dank fuer die Hilfe. Ich habe mein Problem mittels PosEx geloest.

_________________
Information in this online help system is subject to change without notice.