Программы   Загрузка Партнерство   О компании Контакты  
 
                    
  Карта Сайта   
   

Как реализовать поиск по тексту



procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  find: string;
  text: string;
  st, len: integer;
  res: integer;
begin
  if Memo1.SelStart >= Length(Memo1.Text) then
    Memo1.SelStart := 0;
  st := Memo1.SelStart + 1;
  if (Memo1.SelLength <= 0) or (not CheckBox1.Checked) then
  begin
    inc(st, Memo1.SelLength);
    len := Length(Memo1.Text) - st;
  end
  else
    len := Memo1.SelLength;
  text := copy(Memo1.Text, st, len);
  find := Edit1.Text;
  res := pos(find, text);
  if res = 0 then
  begin
    ShowMessage('Search string "' + find + '" not found');
    Exit;
  end;
  Memo1.SelStart := res + st - 2;
  Memo1.SelLength := length(find);
end;

           




Программы  |  Загрузка  |  Партнерство  |  О компании  |  Контакты

Copyright © LSD Software 2006 - 2011