Salut à tous,
J'ai un souci que je n'arrive pas à régler je m'explique:
Je travail sur un petit projet grâce a un défi qui consiste a chercher une image qui représente un cadeau sur un site!!
bref j'ai réussi a utiliser mon programme mais le probleme c'est qu'il n'arrive pas à aller a la 2eme ligne,3 ligne ....
Voila mon code :
Donc le problème viens du fait que si il trouve pas le Mot dans la première page il passe a la suivante exemple:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 function FindTextAll(re: TRichEdit; sText: string; options: TSearchTypes): TIntegerDynArray; var iStart, iFound, iLength: integer; begin SetLength(Result, 0); iStart := 0; iLength := Length(re.Lines.Text); while iStart < (iLength - Length(sText)) do begin iFound := re.FindText(sText, iStart, iLength - iStart, options); if iFound = -1 then Exit; SetLength(Result, Succ(Length(Result))); Result[High(Result)] := iFound; iStart := iFound + Length(sText); end; end; procedure TForm1.Button2Click(Sender: TObject); var F:textfile; lig:string; start: integer; TextCherche: string; ida: TIntegerDynArray; begin {$I-} FileMode :=0; assignfile(F,'cadeaux.txt'); reset(F); while not eof(F) do begin readln(F,lig); edit2.Text:=lig; Richedit1.Text:=idhttp1.Get('http://www.cool.fr/'+edit2.Text); //Edit2 recupère la ligne dans le fichier texte TextCherche := Edit3.Text; //mot a Chercher ida := FindTextAll(RichEdit1, TextCherche, []); for i := Low(ida) to High(ida) do with RichEdit1 do begin SelStart := ida[i]; SelLength := Length(TextCherche); RichEdit1.SetFocus; end; with TStringList.Create do begin label1.Caption :=(IntToStr(Count)); Free; if RichEdit1.SelStart <> 0 then label1.Caption :='message trouvé' else label1.Caption :='message non trouvé'; end; closefile(F); end; end; end.
si Cadeau est pas dans page1 alors page2 si cadeau est dans page2 alors stop
Si une personne pourrez m'aider car la je bloque
merci d'avance pour votre aide.
Partager