Program TEXT(S1: string);

{ Performs a simple text search }

var tc,tag,rc,n,i,o,j,k,tot,nr,y: real;
    dbname,fld,s,r: string;

Begin
clear;
dbname:=dbn;
if dbname='' then
   begin
   msg(1); readln(dbname);
   open(dbname);
   end;
write('Data base name: ',dbname);
cursor(2,1); write('Tag to be searched?    ');
cursor(3,1); write('String to be searched? ');

repeat
box(5,2,16,78,2);
r:='';
cursor(2,24); write('     '); cursor(2,24);
readln(s);
if s<>'' then
   begin
   tag:=val(s);
   cursor(3,24); write('                       '); cursor(3,24); readln(s);
   uc(s);
   i:=0; y:=0; nr:=0; tot:=0; tc:=0;
   cursor(22,1); writeln('Records retrieved:          ');
   repeat
   i:=i+1;   rc:=record(i);
   tc:=tc+1;
   cursor(5,5); writeln(i:1);
   if rc=0 then
      begin
      nr:=nr+1; n:=nocc(tag); o:=0;
      while o<n do
      begin
      o:=o+1;
      j:=fieldn(tag,o); fld:=field(j); uc(fld); k:=position(fld,s,1);
      if k<>0 then
         begin
         Y:=Y+1;
         k:=format(70); o:=6;
         clearbox(6,3,14,76,1);
         while (nxtline(fld)=0) and (o<19) do
           begin cursor(o,5); writeln(fld); o:=o+1; end;
         cursor(22,20); write(y:1,'  '); r:=inkey; uc(r);
         clearbox(6,3,14,76,0);
         tc:=0;
         end;
      end;
      end;
   if tc=100 then
      begin
      cursor(23,1);
      write('<CR> - continue for 100 more records   X - Exit --> ');
      r:=inkey; uc(r);
      tc:=0;
      end;
   until (rc<0) or (r='X');
   end;
until (s='') or (r='X');
s1:=' ';
end.
