Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi EOF für Strings? (https://www.delphipraxis.net/15884-eof-fuer-strings.html)

Gambit 5. Feb 2004 18:23


EOF für Strings?
 
Hallo,

ich parse eine HTML-Seite, die ich auf einen String gelegt habe in einer Schleife nach einem bestimmten Wort. Hab ich es gefunden, kann ich die Schleife verlassen, das ist kein Problem. Wird das Wort aber nicht gefunden, gerate ich in eine Endlosschleife. Wie kann ich die Schleife verlassen, gibt es sowas wie EOF auch für Strings?

Gruß

Gambit

RomanK 5. Feb 2004 18:29

Re: EOF für Strings?
 
Hoi,
du musst die Stellen mitzählen und wenn du dann bei length(DEINSTring)-1 bist aufhören.
LENGTH gibt die Anzahl der Zeichen in einem String an.

Bobator 5. Feb 2004 18:29

Re: EOF für Strings?
 
Poste mal den Quelltext.

MrKnogge 5. Feb 2004 18:30

Re: EOF für Strings?
 
Delphi-Quellcode:
length(MeinString)
gibt dir die länge deines Strings zurück.

chris 5. Feb 2004 18:33

Re: EOF für Strings?
 
hi,

guck dir dazu auch mal pos() an!

Gambit 5. Feb 2004 18:39

Re: EOF für Strings?
 
ok, hier mal der Quelltext, is alles noch Probiererei...


Delphi-Quellcode:
if CBStrongSearch.Checked = true then
  begin
    Pos1:=ansiPos('<LI>', htmlcode);
    Delete(htmlcode, 1, Pos1-1);
    foundTitle:= false;

      While foundTitle = false do
      begin
        Pos2:=ansiPos('</A>', htmlcode);
        NewString:=ansiMidStr(htmlcode,1,Pos2+3);
        If AnsiContainsText(NewString, edit1.Text+'</A>') then foundTitle:= true
        else Delete(htmlcode, 1, Pos2+3);
        If ansiMidStr(htmlcode, 1,4)<>'<LI>' then
        begin
          showMessage('Nicht gefunden');
          break;
        end;
      end;
   
    showMessage(NewString);
  end else
die Stelle mit dem Break funzt nicht.

Hier mal ein Ausschnitt aus dem HTML-Code:

[/B]</FONT>

<FONT SIZE = "2" FACE = "arial" COLOR = "black">

<UL>

<LI><A HREF = "/entertainment/djfl/1110/111216.html"> A Beautiful Mind</A>
<LI><A HREF = "/entertainment/djfl/1000/100028.html"> A Chinese Star Story</A>
<LI><A HREF = "/entertainment/djfl/1065/106672.html"> A Good Man In Africa</A>
<LI><A HREF = "/entertainment/djfl/1050/105027.html"> A Hard Day's Night</A>
<LI><A HREF = "/entertainment/djfl/1100/110453.html"> A Night At The Roxbury</A>
<LI><A HREF = "/entertainment/djfl/1110/111054.html"> A. I. - Künstliche Intelligenz</A>
<LI><A HREF = "/entertainment/djfl/1080/108256.html"> Abbuzze! - Der Badesalz-Film</A>
<LI><A HREF = "/entertainment/djfl/1065/106673.html"> Abendanzug</A>
<LI><A HREF = "/entertainment/djfl/1100/110281.html"> Abgefahren</A>
<LI><A HREF = "/entertainment/djfl/1115/111586.html"> Abgezockt!</A>
<LI><A HREF = "/entertainment/djfl/1110/111331.html"> About A Boy</A>

Gruß

Gambit


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:20 Uhr.

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