All pastes #2066926 Raw Edit

Untitled

public text v1 · immutable
#2066926 ·published 2011-05-22 14:48 UTC
rendered paste body
procedure TForm1.POISKClick(Sender: TObject);
var z,s, x2,x,x1, y:string;
search,zapolnenie:Boolean;
i,l:integer;
begin
  AssignFile(f,'1.txt.txt');
  reset(f);
  numzap:=0;
  Kolfind:=0;
  search:=false;
  for I := 0 to tabliza.RowCount - 1 do
    tabliza.Rows[I].Clear;
while not Eof(f) do
begin
  readln (f,x);
  zapolnenie:=false;
  if (copy(x,1,2)='**') and (copy(x,length(x)-1,2)='**') and (x <>'****') then
  numzap:=strtointdef(Copy(x,3,length(x)-4),0);

  if copy (x,1,9)= '{caption}' then
   begin
     Delete(x,1,9);
     zagolovok:=x;
   end;

if copy (x,1,8)='{addstr}' then
begin
  delete(x,1,8);
  if Vyb1.ItemIndex=0 then   //0-начинается
    begin
      y:=Poisk1.Text;
      y:=' '+AnsiLowerCase(Trim(y));
      x1:=' '+AnsiLowerCase(Trim(x));
    end;

  if Vyb1.ItemIndex=1 then     //1-содержит
    begin
      y:=Poisk1.Text;
      y:=AnsiLowerCase(Trim(y));
      x1:=AnsiLowerCase(Trim(x));
    end;

  if Vyb1.ItemIndex=2 then //2-равно
    begin
     y:=Poisk1.Text;
     y:=' '+AnsiLowerCase(Trim(y))+' ';
     x1:=' '+ AnsiLowerCase(Trim(x))+' ';
    end;

  if Vyb2.ItemIndex=0 then//начинается
    begin
     z:=poisk2.Text;
     z:=' '+AnsiLowerCase(trim(z));
     x2:=' '+AnsiLowerCase(trim(x));
    end;

  if Vyb2.ItemIndex=1 then//содержит
    begin
     z:=poisk2.Text;
     z:=AnsiLowerCase(trim(z));
     x2:=AnsiLowerCase(trim(x));
    end;

  if Vyb2.ItemIndex=2 then//равно
    begin
     z:=poisk2.Text;
     z:=' '+AnsiLowerCase(trim(z))+' ';
     x2:=' '+AnsiLowerCase(trim(x))+' ';
    end;
end;

if copy (x,1,9)='{addstr2}' then
begin
  delete(x,1,9);
  if Vyb1.ItemIndex=0 then   //0-начинается
    begin
      y:=Poisk1.Text;
      y:=' '+AnsiLowerCase(Trim(y));
      x1:=' '+AnsiLowerCase(Trim(x));
    end;

  if Vyb1.ItemIndex=1 then     //1-содержит
    begin
      y:=Poisk1.Text;
      y:=AnsiLowerCase(Trim(y));
      x1:=AnsiLowerCase(Trim(x));
    end;

  if Vyb1.ItemIndex=2 then //2-равно
    begin
     y:=Poisk1.Text;
     y:=' '+AnsiLowerCase(Trim(y))+' ';
     x1:=' '+ AnsiLowerCase(Trim(x))+' ';
    end;

  if Vyb2.ItemIndex=0 then//начинается
    begin
     z:=poisk2.Text;
     z:=' '+AnsiLowerCase(trim(z));
     x2:=' '+AnsiLowerCase(trim(x));
    end;

  if Vyb2.ItemIndex=1 then//содержит
    begin
     z:=poisk2.Text;
     z:=AnsiLowerCase(trim(z));
     x2:=AnsiLowerCase(trim(x));
    end;

  if Vyb2.ItemIndex=2 then//равно
    begin
     z:=poisk2.Text;
     z:=' '+AnsiLowerCase(trim(z))+' ';
     x2:=' '+AnsiLowerCase(trim(x))+' ';
    end;
end;


  if Alternativa.ItemIndex=0 then
      if Poisk2.Text<>'' then
      begin
      if (pos(y,x1)>0) and (pos(z,x2)>0) then search:=true;
      {if (pos(y,x1)>0) and (pos(z,x2)>0) and ((vyb1.ItemIndex=1)or(vyb1.ItemIndex=0)) and ((vyb2.ItemIndex=1)or(vyb2.ItemIndex=0)) then search:=true;
      if (pos(y,x1)=0) and (pos(z,x2)=0) and (vyb1.ItemIndex=2) and (vyb2.ItemIndex=2) then search:=true;
      if (pos(y,x1)>0) and (z=x2) and ((vyb1.ItemIndex=1)or(vyb1.ItemIndex=0)) and (vyb2.ItemIndex=2) then search:=true;
      if (y=x1) and (pos(z,x2)>0) and (vyb1.ItemIndex=2) and ((vyb2.ItemIndex=1)or(vyb2.ItemIndex=0)) then search:=true;}
       //   caption:=caption+inttostr(Kolfind)+'!';

      end
      else
      begin
      if (pos(y,x1)>0) and ((vyb1.ItemIndex=0)or(vyb1.ItemIndex=1)) then search:=true;
      if (y=x1) and (vyb1.ItemIndex=2) then search:=true;
      end;
  if Alternativa.ItemIndex=1 then
      if Poisk2.Text<>'' then
      begin
      if (pos(y,x1)>0) or (pos(z,x2)>0) then search:=true;
      end
      else
      begin
      if (pos(y,x1)>0) and ((vyb1.ItemIndex=0)or(vyb1.ItemIndex=1)) then search:=true;
      if (y=x1) and (vyb1.ItemIndex=2) then search:=true;
      end;
       //   caption:=caption+inttostr(Kolfind)+'!';

     {
      else
        if Trim(Poisk1.Text)='' then
        begin
          if pos(z,x2)>0 then
          search:=true;
      //    Kolfind:=Kolfind+1;
        end;
        if Trim(Poisk2.Text)='' then
        begin
          if pos(y,x1)>0 then
          search:=true;
      //    Kolfind:=Kolfind+1;
        end;
      end;
              }
  { if Alternativa.ItemIndex=1 then
      begin
        if (pos(y,x1)>0) or (pos(z,x2)>0) then
        begin
          search:=true;
      //    Kolfind:=Kolfind+1;
        end;
       if Trim(Poisk1.Text)='' then
          begin
            if pos(y,x2)>0 then
            search:=true;
          //  Kolfind:=Kolfind+1;
          end;
         if Trim(Poisk2.Text)='' then
          begin
            if pos(z,x1)>0 then
            search:=true;
         //   Kolfind:=Kolfind+1;
          end;
      end;
        }
 // end;
 
  if x='****' then zapolnenie:=true;

  
  if zapolnenie and search then
     begin
     Kolfind:=Kolfind+1;
     Tabliza.RowCount:=Kolfind+1;
     Tabliza.Cells[0,kolfind]:=inttostr(Kolfind);
     Tabliza.Cells[1,Kolfind]:=zagolovok;
     Tabliza.Cells[2,Kolfind]:=inttostr(numzap);

     {s:=zagolovok+'!!!'+inttostr(numzap);
     listbox1.Items.Add(s);}

     zapolnenie:=false;
     search:=false;
     end;
     (**)
  end;
{for i:=1 to kolfind do
  begin
  s:=listbox1.items[i-1];
  L:=pos('!!!',s);
  tabliza.Cells[1,i]:=copy(s,1,L-1);
  delete(s,1,L+2);
  tabliza.Cells[2,i]:=s;
  end;}
CloseFile(f);
end;