Szukaj frazy, jedź dalej - until z małym problemem

0

Mam linie:
if Pos('blabla', Output.DataString) 0 then....cos tam robi

Chce, aby po znalezieniu tej linii, dalej szukał, i to tego samego(i nie wracał znowu na sam początek tekstu, tylko dalej jechał). Niestety nie zrobie:

if Pos('blabla', Output.DataString) 0 then
repeat
Pos('blabla', Output.DataString) cos tam rob...
until
Pos('blabla', Output.DataString) = 0
end;
...ponieważ on będzie szukał od początku textu(tak sie mi zrobiło i zawiesił się program) :-P

0

To działaj na kopii zmiennej, którą będzie substring od końca pozycji znalezionej do końca textu i tak w pętelce...

0

Lepiej uzyj FindText + F1

example from Help:

This example requires a TRichEdit, a TButton, and a TFindDialog.
Clicking the button click will display a Find Dialog to the right of the edit control. Filling in the "Find what" text and pressing the Find Next button will select the first matching string in the Rich Edit control that follows the previous selection.

procedure TForm1.Button1Click(Sender: TObject);

begin
FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top);
FindDialog1.Execute;
end;

procedure TForm1.FindDialog1Find(Sender: TObject);
var
FoundAt: LongInt;
StartPos, ToEnd: Integer;
begin
with RichEdit1 do
begin
{ begin the search after the current selection if there is one }
{ otherwise, begin at the start of the text }
if SelLength 0 then

  StartPos := SelStart + SelLength
else

  StartPos := 0;

{ ToEnd is the length from StartPos to the end of the text in the rich edit control }

ToEnd := Length(Text) - StartPos;

FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, [stMatchCase]);
if FoundAt  -1 then
begin
  SetFocus;
  SelStart := FoundAt;
  SelLength := Length(FindDialog1.FindText);
end;

end;
end;

BTW[0] Wiem, bo wczoraj z tego korzystalem:)
BTW[1] Zamiast pogrubiac kod zrodlowy w postach lepiej uzywaj znacznika

0

Ok, coś wymodze :-P
Thx.

1 użytkowników online, w tym zalogowanych: 0, gości: 1