Autor Beitrag
BigBen4ever
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98



BeitragVerfasst: Sa 18.02.06 18:15 
Moin.
Möchte gerne einen Preis auslesen aus einem in einem Memo enthaltenen Text.
Im Memo sieht der Text wie folgt aus:

<a href="/exec/hgtsg/hg/detail/ofsr-jshs/-/BzgwzgsUL7C/all/ttwgsgs64641">EUR 8,18</a>

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  P:integer;
  Q:integer;
  S:string;
begin
  P:= pos('">EUR ', memo1.text);
  Q:= pos('</a>', memo1.text);
  S:= Copy(P,Pos(' ',p) + 1, Pos('<', q) - 1));
  Edit4.text:=s;
end;


Das war mein Versuch, bekomme die Fehlermeldung inkompatible Typen, bin Delphi Anfänger ...ich weiß wirklich nicht was falsch ist, kann mir jemand helfen?

Ich brauch im Edit4.text folgendes: "8,18"
Würde mein Code dies machen?
Was ist falsch?

Wenn der Code dann funktioniert, wie mache ich es, dass er ganz oben im Memo anfängt also ab Zeile 0 (bzw 1) und bis zum Ende. Also immer wieder nach dieser Pos P sucht und falls die vorhanden ist, am besten die Preise in ein Memo untereinander wegschreiben, das wäre super genial, wenn mir das jemand erklären könnte.

Ok hoffe auf Hilfe, entschuldigt meine Unfähigkeit :(
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 18.02.06 18:42 
also so findet er erst mal den Preis in dem einen String....
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var p:integer;
begin
p:=pos('>EUR ',edit1.text);
edit4.text:=copy(edit1.text,p+5,4);
end;


so funzt copy
ausblenden Quelltext
1:
copy(text_aus_dem_kopiert_wird,startposition_fürs_kopieren,anzahl_der_zeichen_die_kopiert_werden);					


das ist aber nur die halbe miete :wink:
kannst ja erst mal bissel rum suchen ob du das was hier im Forum findest...
Da gebts ne menge Themen wie man in nem Memo nen Text sucht....

_________________
GEIZ IST GEIL! - Ihr Sozialamt


Zuletzt bearbeitet von starsurfer am Sa 18.02.06 18:52, insgesamt 3-mal bearbeitet
thkerkmann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 20

Windows 7
Delphi 2010 Professional
BeitragVerfasst: Sa 18.02.06 18:42 
Hi,
der Fehler steckt in Zeile 8.
das copy sollte doch wohl aus dem Memo kopieren und nicht aus einem integer .....
BigBen4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98



BeitragVerfasst: Sa 18.02.06 19:11 
was muss ich ändern, werde daraus nicht schlau?
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: Sa 18.02.06 19:17 
user profile iconstarsurfer hat folgendes geschrieben:
also so findet er erst mal den Preis in dem einen String....
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var p:integer;
begin
p:=pos('>EUR ',edit1.text);
edit4.text:=copy(edit1.text,p+5,4);
end;


so funzt copy
ausblenden Quelltext
1:
copy(text_aus_dem_kopiert_wird,startposition_fürs_kopieren,anzahl_der_zeichen_die_kopiert_werden);					


das ist aber nur die halbe miete :wink:
kannst ja erst mal bissel rum suchen ob du das was hier im Forum findest...
Da gebts ne menge Themen wie man in nem Memo nen Text sucht....


Stimmt schon nur würde ich das gehighlighte abändern in Pos('</a>', Edit1.Text) denn was ist denn mit EUR 2 oder EUR 344,46? ;)


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.
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 18.02.06 19:23 
hast ja recht :oops:

aber
ausblenden Quelltext
1:
abändern in Pos('</a>', Edit1.Text)					

ist auch nicht ganz richtig 8)

dann so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);  
var p1,p2:integer;  
begin  
p1:=pos('>EUR ',edit1.text)+5;
p2:=pos('</a>',edit1.text);  
edit4.text:=copy(edit1.text,p1,p2-p1);  
end;
:wink:

_________________
GEIZ IST GEIL! - Ihr Sozialamt
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: Sa 18.02.06 19:34 
Stimmt hast Recht...

war grad ein bisschen verwirrt :gruebel: ^^
Jetzt müsste es ihm aber klar sein..

Noch ne frage: Warum nennst du deine Memos EditX?


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.
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 18.02.06 19:42 
weil der Algo iM völlig unnütz für ne Memo Suche is( er findet ja nur den ersten Eintrag)...

so hab ichs erst mal mit 2 Edit´s gemacht :) (um de Funktionsweise zu zeigen)

_________________
GEIZ IST GEIL! - Ihr Sozialamt
BigBen4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98



BeitragVerfasst: Sa 18.02.06 19:58 
und wie mache ich das dann als schleife?
bin da echt ratlos hab grad ne stunden mitm freund telefoniert, wir kriegen das nicht hin...

bitte helft mir :(
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 18.02.06 20:09 
kommt der preis in dem memo...

genau einmal vor?
genau einmal pro zeile vor?
unterschiedlich oft pro zeile vor? (0..WerWeisWieOft)

zusätzlich:
ist das im memo ein html text mit diversen zeilen, und kommt "</a>" öfters vor?

_________________
GEIZ IST GEIL! - Ihr Sozialamt


Zuletzt bearbeitet von starsurfer am Sa 18.02.06 20:30, insgesamt 5-mal bearbeitet
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: Sa 18.02.06 20:11 
user profile iconstarsurfer hat folgendes geschrieben:
weil der Algo iM völlig unnütz für ne Memo Suche is( er findet ja nur den ersten Eintrag)...

so hab ichs erst mal mit 2 Edit´s gemacht :) (um de Funktionsweise zu zeigen)



Achsooo ich hatte mich verlesen :oops: Ich dachte der Autor hat auch Edits genommen.. sry ^^

_________________
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.
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: Sa 18.02.06 20:17 
Zu der Schleife.. ich würde es so machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  mText: String;
begin
  mText := Memo1.Text;
  Edit1.Text := '';
  repeat
    Edit1.Text := Edit1.Text + Copy(mText, Pos('EUR ', mText) + 4, Pos('</a>', mText) - Pos('EUR ', mText) - 4) + '; ';
    mText := Copy(mText, Pos('</a>', mText) + 5, Length(mText));
  until Pos('</a>', mText) = 0;
end;


ungetestet und geht bestimmt noch zu vebessern


greetz


//EDIT: Fehler verbessert ^^

_________________
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.
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 18.02.06 20:32 
born-to-frag:

was ist wenn das ein kompletter html text ist in dem "</a>" öters vorkommt ?

und vor der preisangabe schon mal ein "</a>" steht? dann kommt da murks raus..

wir brauchen werst ma mehr infos zu dem text..

siehe mein post weiter oben...

_________________
GEIZ IST GEIL! - Ihr Sozialamt
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: Sa 18.02.06 20:35 
Ich bin ja davon ausgagangen das immer nur diese Preisdinger kommen 8)

_________________
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.