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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
procedure Tchercher.Button3Click(Sender: TObject);
var
tab: array of array of string;
tab_resu: array of integer;
fich_elem: textFile;
lig,mot,foto,num,mot_cher,desi,texte:string;
saut,a,i,j,y,test,nb_lig_fich,lign: integer;
begin
Screen.Cursor:= crHourGlass;
donnee:= ExtractFilePath(Application.ExeName)+'donne_collec.txt';
AssignFile(fich_elem,donnee);Reset(fich_elem);
SetLength(tab,FileSize(fich_elem),20);
SetLength(tab_resu,FileSize(fich_elem));
avance.Max:=FileSize(fich_elem)+1;
enregcollec.index:=0;
nb_lig_fich:=0;
While not EOF(fich_elem) do
begin
ReadLn(fich_elem,lig);saut:=0;mot:='';
nb_lig_fich:=nb_lig_fich+1;
avance.Position:=nb_lig_fich;
for i:=1 to length(lig) do
begin
if ord(lig[i])<>35 then mot:=mot+char(ord(lig[i]))
else
begin
//**********************************************
if saut=0 then
//----------------------------------------------------
begin
mot:=trim(mot);
num:='';y:=length(mot);test:=0;
for j:=1 to y do
begin
if ord(mot[j])<>48 then test:=1;
if test=1 then num:=num+char(ord(mot[j]));
end;
tab[nb_lig_fich,saut]:=num;
end;
//**********************************************
if saut=1 then
begin
tab[nb_lig_fich,saut]:=mot;
//--------------------------------------------------------
mot_cher:=trim(edit6.text);
mot_cher:=Lowercase(mot_cher);
mot_cher:=StrReplace( 'é','e',mot_cher);
mot_cher:=StrReplace( 'è','e',mot_cher);
mot_cher:=StrReplace( 'à','a',mot_cher);
desi:=Lowercase(mot);
desi:=StrReplace( 'é','e',desi);
desi:=StrReplace( 'è','e',desi);
desi:=StrReplace( 'à','a',desi);
y:=length(desi);
texte:='';
for a:=1 to y do
begin
if desi[a]<>' ' then texte:=texte+desi[a];
if desi[a]=' ' then
begin
if texte=mot_cher then
begin
lign:=lign+1;
tab_resu[lign]:=nb_lig_fich;
end;
texte:='';
end; // if desi=' '
end; // fin de boucle a
end; // fin de if saut=1
//--------------------------------------------------------
if saut=2 then tab[nb_lig_fich,saut]:=mot;
if saut=3 then tab[nb_lig_fich,saut]:=mot;
if saut=4 then tab[nb_lig_fich,saut]:=mot;
if saut=5 then tab[nb_lig_fich,saut]:=mot;
if saut=6 then tab[nb_lig_fich,saut]:=mot;
if saut=7 then tab[nb_lig_fich,saut]:=mot;
if saut=8 then tab[nb_lig_fich,saut]:=mot;
if saut=9 then tab[nb_lig_fich,saut]:=mot;
if saut=10 then
//--------------------------------------------------------
begin
foto:='';y:=length(mot);test:=0;
for j:=1 to y do
begin
foto:=foto+char(ord(mot[j]));
if ord(mot[j])=46 then test:=1;
if test=1 then
begin
foto:=foto+'bmp';
tab[nb_lig_fich,saut]:=foto;
test:=2;
end;
end;
end;
//--------------------------------------------------------
if saut=12 then tab[nb_lig_fich,saut]:=mot;
if saut=13 then tab[nb_lig_fich,saut]:=mot;
if saut=14 then tab[nb_lig_fich,saut]:=mot;
if saut=15 then tab[nb_lig_fich,saut]:=mot;
if saut=16 then tab[nb_lig_fich,saut]:=mot;
if saut=17 then tab[nb_lig_fich,saut]:=mot;
if saut=18 then tab[nb_lig_fich,saut]:=mot;
//-------------------------------------------------------
if ord(lig[i])=35 then
begin
saut:=saut+1;mot:='';
end;
end; //fin de else
end;
end;
CloseFile(fich_elem);
chercher.grille.RowCount:=lign+1;
if lign=0 then label5.Caption:='Aucune correspondance';
for i:=1 to lign do
begin
seek(fichier,tab_resu[i]);read(fichier,enregcollec);
chercher.grille.Cells[0,i]:=enregcollec.num ;
chercher.grille.Cells[1,i]:=enregcollec.desi;
//tri.grille.Cells[2,i]:=CurrToStr(tab_resu[i].c);
//grille.Cells[3,i]:=tab_liste[i,5];
end; // fin de i
Screen.Cursor:= crDefault;
end; |
Partager