L'objectif de ce logiciel (cadre 5) est de compléter les détails des entrées déjà définies dans la base originale (cadre1 et 2).Cette base est suffisamment simple pour être gérée à la main, mais elle contient tout de même plus d'une centaine d'entrées différentes qui ont été additionnées progressivement.

Sont ajoutés: les références antérieures dans la base, le numéro d'ordre,le nombre d'image par url et la taille de ces images(cadre 3 et 4).

Au passage la taille des fichiers et leur nombre sont évalués

La base en action sur site.

<HTML>
...
<CENTER><TABLE BORDER=2 >
<TR><TD align=center>
<H2>CATALOGUE DES TRAVAUX PAR ELEVE</H2>
</TD></TR><tr><td><br><b><h3>Espace Représenté et Perspective Centrale</h3></b></td></tr>
<tr><td align=center><b><A HREF="pers2.htm">Laétitia B....</A></b></td></tr>
<tr><td align=center><b><A HREF="pers4.htm">Patrick P....</A></b></td></tr>
<tr><td align=center><b><A HREF="pers12.htm">Christophe C.....</A></b></td></tr>
...
</HTML>

CATALOGUE DES TRAVAUX PAR ELEVE


Espace Représenté et Perspective Centrale
Laétitia B....
Patrick P....
Christophe C.....
....
<HTML>
...
<CENTER><TABLE BORDER=2 ><TR><TD colspan=9 align=center><H2>
CATALOGUE DES TRAVAUX PAR ELEVE </H2></TD></TR><tr><td>autres travaux</td>
<td>nø</td><td>nom</td><td colspan=4>nombre d'images</td><td>taille</td><td>autres travaux</td>
</tr><tr><td colspan=9><br><b><h3>Espace Représenté et Perspective Centrale</h3></b></td></tr>
<tr><td> </td><td><a name="1"></a><b>1</b></td>
<td align=center><b><A HREF="pers2.htm">Laétitia B....</A></b></td><td colspan=4>
1 img </td><td>13K</td><td><a HREF="#81">Suivant</a></td></tr><tr><td> </td><td>
<a name="2"></a><b>2</b></td><td align=center><b>
<A HREF="pers4.htm">Patrick P....</A></b></td>
<td colspan=4>1 img</td><td>17K</td><td> </td>
</tr>
...
</HTML>

CATALOGUE DES TRAVAUX PAR ELEVE

autres travauxnom nombre d'imagestailleautres travaux

Espace Représenté et Perspective Centrale
 1Laétitia B....1 img 13KSuivant
 2Patrick P....1 img 17K 
 3Christophe C.....1 img 15KSuivant
...

uses dos,crt;
type listeptr=^liste;
     liste=array[0..254] of string;

     ancrenom=record
                    Anombre:integer;
                    Anom:string[30];
                    Asuivant:integer;
                    Aprecedent:integer;
                    nimg:integer;
                end;

     listeAptr=^liste_a;
     liste_a= array[0..254] of ancrenom;

var f,f2:text;
    dirinfo:searchrec;
    lf,opath,dirpath,lftemp:string;
    liste1, liste2: listeptr;
    listea:  listeAptr;
    x,l,h,z,t,n,nblgn,
    y1,partic,orign:integer;
    y:word;
    nom,prenom,buf,buf2,buf3,
          buf4,buf5,buf6,buf7,
          pl,hfic:string;
    car:char;
    numimg,numimgmax:integer;
     longueur,
     pntnom,
     tailletotaleimg,
     tailletotalehtm,
     nombretotalimg,
     nombretotalhtm,
     nombretotalelv:longint;
     maxfiltre:integer;
     themegeneraux:integer;


procedure filtreliste(var x:integer);
var y:integer;
begin
for y:=x+1 to pntnom do
    begin
         if listea^[y].anom=nom then
          begin
            if listea^[y].aprecedent=0 then listea^[y].aprecedent:=x;
            if listea^[x].asuivant=0 then listea^[x].asuivant:=y;
            filtreliste(y);
          end;
    end;
end;

procedure extrait_nom(compte_eleve:boolean);
var nbv:integer;   augmnbelv:boolean;
begin
(* on cherche un point de repère pour la ...*)
            if pos('align=center><b><A',lf)<>0 then
            begin
            (* ...récupération du nom: 'align=center' se trouve
               necessairement dans une ligne où se trouve un nom *)
                 z:=0;
                 buf[0]:=#1;
                 (*
                   Le nom est juste avant le tag de fin d'ancre '</a>'.
                   il est précédé d'un espace vide ...
                   on le récupère à l'envers.
                 *)
                 while (car<>' ') do
                 begin
                      car:=lf[pos('</A>',lf)-1-z];
                      buf[0]:=chr(z+1);
                      buf[z+1]:=car;
                      inc(z);
                 end;

                 car:=#0;
                 t:=0;
                 nom[0]:=chr(z-1);

                 (*
                  on le remet à l'endroit:
                 *)
                 for h:=z-1 downto 1 do
                 begin
                      inc(t);
                      nom[t]:=buf[h];
                 end;
                 (*
                  on évacue le nom pour faciliter la récupération
                  du prénom
                 *)
                 delete(lf,pos('</A>',lf)-length(nom)-1,length(nom)+1);
                 (* récupération du prénom*)
                 z:=0;
                 buf[0]:=#1;
                 (*
                  même procédure en gros que pour le nom..
                 *)
                 while (car<>'>') do
                 begin
                      car:=lf[pos('</A>',lf)-1-z];
                      buf[0]:=chr(z+1);
                      buf[z+1]:=car;
                      inc(z);
                 end;
                 car:=#0;
                 t:=0;
                 prenom[0]:=chr(z-1);
                 for h:=z-1 downto 1 do
                 begin
                      inc(t);
                      prenom[t]:=buf[h];
                 end;
                 (*
                   c'est donc un nom supplémentaire récupéré dans le fichier
                   on le note dans pntnom
                 *)
                 inc(pntnom);
                 (*
                   on documente la liste de nom
                 *)
                 listea^[pntnom].anom:=prenom+' '+nom;
                 listea^[pntnom].anombre:=0;
                 if compte_eleve then
                 begin
                 augmnbelv:=true;
                 for nbv:=0 to pntnom-1 do
                 begin
                   if  listea^[pntnom].anom=listea^[nbv].anom then
                   augmnbelv:=false;
                 end;

                 if augmnbelv then inc(nombretotalelv);
                 end;
                 (*
                   restauration de l'état du tampon pour d'autres
                   opérations
                 *)
                 lf:=liste1^[x];
            end;

end;

var thumbimg,
    thumbtaille:longint;
(* *)
procedure docoriginefile;
var f,f2:text;
    dirpath,lf,
     nom    :string;
    t,x,y,z,
    u,v,n       :integer;
    car         :char;
    dirinfo:searchrec;
    theme:integer;

begin    (* 0 *)
 theme:=0;
 thumbtaille:=0;
 tailletotalehtm:=0;
 (*
   documenter l'adresse du repertoire
 *)
 dirpath:='d:\internet\htdogpro\site_int\atlrinfo';
 (*
   Comme on a déjà fait le travail au moins une fois
   la taille de ces fichiers peut être ajoutée à la taille
   globale de l'ensemble
 *)
 findfirst('basenw2.htm',anyfile,dirinfo);
 tailletotalehtm:=tailletotalehtm+dirinfo.size;
 findfirst(dirpath+'\quelqdes.htm',anyfile,dirinfo);
 tailletotalehtm:=tailletotalehtm+dirinfo.size;
 (*
   on peut commencer: on ouvre le fichier cible, qui contient une serie d'url
   sur des pages thématiques qui regroupent les 'thumbnails' des travaux
   d'élèves. Rencontrer une url revient à identifier un
   thême.
 *)
 assign(f,dirpath+'\quelqdes.htm');
 reset(f);
  (*
   on repete cette opération jusqu'à la fin du fichier
  *)
   while not eof(f) do
     begin       (* 1 *)
     (*  lire une ligne de texte     *)
        readln(f,lf);
       (* si on repere une URL       *)
        if pos('HREF="',lf)<>0 then
        begin    (* 2 *)
        (* on recupere le contenu de l'adresse*)
           y:=0;
           t:=pos('HREF="',lf)+6;
           while lf[t]<>'"' do
           begin  (* 3 *)
              inc(y);
              nom[0]:=chr(y);
              nom[y]:=lf[t];
              inc(t);
           end;   (* 3 *)
         (* on met à jour le compteur de thême. *)
         inc(theme);
           (* certaines feuilles ne contiennent qu'une seule 
              référence qui pointe directement
              sur une feuille unique avec ses images au format
              définitif qui se trouve dans un sous 
              répertoire, elles sont traitées
              à part sinon...
              pour le traitement de ces exceptions allez en *10*.
           *)  
           if  pos('/',nom)=0 then
           begin  (* 4 *)
             findfirst(dirpath+'\'+nom,anyfile,dirinfo);
             tailletotalehtm:=tailletotalehtm+dirinfo.size;

             assign(f2,dirpath+'\'+nom);
             reset(f2);
                while not eof(f2) do
                begin  (* 6 *)
                    readln(f2,lf);
                    if pos('IMG ',lf)<>0 then
                    begin  (* 7 *)
                         y:=0;
                         t:=pos('SRC="',lf)+5;
                         while lf[t]<>'"' do
                         begin (* 8 *)
                              inc(y);
                              nom[0]:=chr(y);
                              nom[y]:=lf[t];
                              inc(t);
                         end;  (* 8 *)
                         while pos('/',nom)<>0 do
                         begin (* 9 *)
                             insert('\',nom,pos('/',nom));
                             delete(nom,pos('/',nom),1);
                         end;  (* 9 *)
                         findfirst(dirpath+'\'+nom,anyfile,dirinfo);
                         thumbtaille:=thumbtaille+dirinfo.size;
                         inc(thumbimg);
                    end;   (* 7 *)
                end;     (* 6 *)
             close(f2);
           end   (* 4 *)
           else
           begin (* 10 *)
               if pos('IMG ',lf)<>0 then
                    begin  (* 11*)
                         y:=0;
                         t:=pos('SRC="',lf)+5;
                         while lf[t]<>'"' do
                         begin (* 12*)
                              inc(y);
                              nom[0]:=chr(y);
                              nom[y]:=lf[t];
                              inc(t);
                         end;  (* 12*)
                         while pos('/',nom)<>0 do
                         begin (* 13*)
                             insert('\',nom,pos('/',nom));
                             delete(nom,pos('/',nom),1);
                         end;  (* 13*)
                         findfirst(dirpath+'\'+nom,anyfile,dirinfo);
                         thumbtaille:=thumbtaille+dirinfo.size;
                         inc(thumbimg);
                    end;   (* 11*)
           end;  (* 10 *)
        end;    (* 2 *)
     end;    (* 1 *)
 close(f);
     numimgmax:=0;
     tailletotaleimg:=thumbtaille;
     nombretotalimg:=thumbimg;
     nombretotalhtm:=theme+2;
     nombretotalelv:=0;
     maxfiltre:=0;
     themegeneraux:=theme;
end;

begin
(* *)
     docoriginefile;

     dirpath:=paramstr(1);
     (*
      pour preserver le fichier original d'une erreur de programmation
     *)
     assign(f,dirpath+'\baselvs.htm');
     reset(f);
     assign(f2,'basenew.htm');
     rewrite(f2);
     (*
       on lit et on copie sur le fichier local
       *)
     while not eof(f) do
     begin
     readln(f,lf);
     x:=1;
     z:= length(lf);
     (*
       on en profite pour passer les refs à des
       fichiers sur système unic en basdecase
     *)
     while x<length(lf) do
         begin
          if lf[x]='"' then
            begin
                 y:=x+1;
                 car:=lf[y];
                 while car<>'"' do begin
                       car:=lf[y];
                       if (car in ['A'..'Z'])
                       and (car<>'"') then lf[y]:=chr(ord(lf[y])+32);
                       inc(y); if y>=length(lf) then car:='"';
                 end;
                 car:=lf[y];
                 x:=x+y; if x>length(lf) then x:=length(lf);
            end;
            inc(x);
         end;
     writeln(f2,lf);
     end;
     (*
       c'est fait on ferme tout.
     *)
     close(f2);
     close(f);
      (*
        initialisation de liste  :
        liste 1 contient les strings originales
        liste 2 les strings modifiées et les lignes ajoutées
        listea contient les ancres sur les noms d'élèves
      *)
     new(liste1);
     new(liste2);
     new(listea);
     fillchar(listea^,sizeof(listea^),#0);
      (*
       mise à jourde la liste 1 sur la base du fichier basenew.htm
       n definit le nombre de ligne à traiter
      *)
     assign(f2,'basenew.htm');
     reset(f2);
       while not eof(f2) do begin readln(f2,liste1^[n]); inc(n); end;
     close(f2);

     (*

     *)
     pntnom:=0;
     (*

     *)
       for x:=0 to n-1 do
       begin     (* 1 *)
           (*  on recupère la ligne dans un tampon de traitement *)
            lf:=liste1^[x];
            extrait_nom(true);
        (*
          le nom que l'on vient de récupérer renvoie à
          un fichier html:
          on doit savoir lequel.
        *)
        if  pos('A HREF="',lf)<>0 then
        begin    (* 2 *)
           t:=pos('A HREF="',lf)+8;
           y:=0;
          (*
           on est sûr de pointer sur un fichier html...on le
           récupère...
          *)
           while lf[t]<>'"' do
             begin   (* 3 *)
              inc(y);
              hfic[0]:=chr(ord(y));
              hfic[y]:=lf[t];
              inc(t);
             end;    (* 3 *)
         (*
          on ajoute l'adresse réelle ...
         *)
        hfic:=dirpath+'\'+hfic;
        (*
         on le pèse...
        *)
          findfirst(hfic,anyfile,dirinfo);
          (*
           on additionne la taille et on augmente le nombre de fichier htm
          *)
          tailletotalehtm:=tailletotalehtm+dirinfo.size;
          inc(nombretotalhtm);
         (*
          on l'ouvre..
         *)
        assign(f,hfic);
        reset(f);

        (*
          filtre le fichier pour trouver toutes les refs à une image
          elles peuvent être nombreuses et rien ne permet de savoir
          combien elles seront au maximum on se sert de numimg pour
          déterminer la quantité qu'il faudra comparer
          à numimgmax
          pour effectuer la documentation de la cellule tableau en
          colspan
        *)
        numimg:=0;

         while not eof(f) do
         begin        (* 4 *)
          (*
            charger une ligne dans le buffer
          *)
           readln(f,pl);
           (*
            chercher le signe d'une image
           *)
           if (pos('IMG SRC="',pl)<>0)  then
              begin     (* 5 *)
                 (*
                  incrémenter le compteur d'image
                 *)
                 inc(numimg);

                 (*
                  positionner un pointeur sur le début du nom de fichier
                 *)
                 t:=pos('IMG SRC=',pl)+9;
                 y:=0;
                 (*
                  récuperer le nom de fichier
                 *)
                 while pl[t]<>'"' do
                 begin      (* 6 *)
                      inc(y);
                      hfic[0]:=chr(ord(y));
                      hfic[y]:=pl[t];
                      inc(t);
                 end;     (* 6 *)
                 (*
                   modifier le nom de fichier pour l'adapter au systeme dos
                 *)
                 insert('\',hfic,pos('/',hfic));
                 delete(hfic,pos('/',hfic),1);
                 (*
                  récupérer l'information de taille
                 *)
                 findfirst(dirpath+'\'+hfic,anyfile,dirinfo);
                 str((dirinfo.size div 1024),buf);
                 tailletotaleimg:=tailletotaleimg+dirinfo.size;
                 (*
                  documenter le buffer lf
                 *)
                 insert('<td>'+buf+'K</td>',lf,pos('</tr>',lf));
                 inc(nombretotalimg);
              end       (* 5 *)
         end;         (* 4 *)
        close(f);
        (*
         savoir si on a dépassé le nombre max d'image par fichier
        *)
        if numimg>=numimgmax then numimgmax:=numimg;
         (*
          mettre à jour la ligne dans le tableau
         *)
        listea^[pntnom].nimg:=numimg;
        str(numimg,buf);
        insert('<td>'+buf+ 
                ' img </td>',
                  lf,
                  pos('</A></b></td>',lf)+13);

        liste1^[x]:=lf;
      end;        (* 2 *)


      if  pos('</TABLE>',lf)<>0 then
           begin    (* 2 *)
              str(tailletotaleimg div 1024,buf);
              str(tailletotalehtm div 1024,buf2);
              str(nombretotalelv ,buf3);
              str(nombretotalhtm ,buf4);
              str(nombretotalimg ,buf5);
              str(thumbimg ,buf6);
              str(themegeneraux,buf7);


             insert('<tr><td align=center><br><b>'+
                       buf5+
                       ' images (dont '+buf6+' thumnails) : '+
                        buf+
                        ' k0 <br>'+
                         buf4+' fichiers htm: '+
                          buf2+' ko<br>'+
                           buf3+' eleves<br>'+
                             buf7+' themes...<br>'+
                             'et un raton laveur</td></tr>',
                              lf,
                              pos('</TABLE>',lf));
             liste1^[x]:=lf;
           end
     end;        (* 1 for x=0 to n-1*)

   (*
    ici listea est à jour de tous les noms possibles, il est temps de filtrer
    les résultats pour savoir si un nom réapparait plusieures fois.
   *)
   for x:=1 to pntnom   do
   begin
    nom:=listea^[x].anom;
    filtreliste(x);
   end;

    pntnom:=0;     (*  on nettoie par sécurité    *)

       for x:=0 to n-1 do
       begin    (* 1 *)
           (*  on recupère la ligne dans un tampon de traitement *)
            lf:=liste1^[x];
            extrait_nom(false);
            (*
              normalement pntnom pointe sur le bon nom dans listea
              et permet de récupérer le nombre d'image par page et
              le comparer à numimgmax
             *)
           if  pos('A HREF="',lf)<>0 then
           begin    (* 2 *)
             numimg:=numimgmax-listea^[pntnom].nimg+1;
             str(numimg,buf);
             insert(' colspan='+buf,lf,pos('</A></b></td>',lf)+16);
             (*
              numérote le nom
             *)
             str(pntnom,buf);
             insert('<td><a name="'+
                     buf+
                     '"></a><b>'+
                      buf+
                      '</b></td>',
                       lf,pos('<tr>',lf)+4);
             if (listea^[pntnom].aprecedent<>0) then
             begin
               str(listea^[pntnom].aprecedent,buf);
              insert('<td><a HREF="#'+
                      buf+
                       '">Precedent</a></td>',
                       lf,
                       pos('<tr>',lf)+4);
             end  else
             insert('<td> </td>',
                      lf,pos('<tr>',lf)+4);
             if (listea^[pntnom].asuivant<>0) then
             begin
               str(listea^[pntnom].asuivant,buf);
               insert('<td><a HREF="#'+                            
                       buf+
                        '">Suivant</a></td>',
                            lf,
                              pos('</tr>',lf));
             end else insert('<td> </td>',
                               lf,pos('</tr>',lf));
             liste1^[x]:=lf;
          end
          else
           if  pos('<tr><td><br><b><h3>',
                        lf)<>0 then
           begin    (* 2 *)
               numimg:=numimgmax+5;
             str(numimg,buf);
             if (length(lf)+8+length(buf))<255 then
             begin
               insert(' colspan='+
                            buf,
                            lf,
                  pos('<tr><td><br><b><h3>',
                        lf)+7);
               liste1^[x]:=lf;
             end
             else
             begin
               for nblgn:=x+1 to n-1 do liste2^[nblgn+1]:=liste1^[nblgn];
               inc(n);
               liste1^[x+1]:='';
               for nblgn:=x+1 to n-1 do liste1^[nblgn+1]:=liste2^[nblgn+1];
             end;
           end
           else
          if  pos('<TR><TD align=center><H2>',lf)<>0 then
           begin    (* 2 *)
             numimg:=numimgmax+5;
             str(numimg,buf);
             insert(' colspan='+
                       buf,lf,
                        pos('<TR><TD align=center><H2>',
                          lf)+7);
             liste1^[x]:=lf;
           end;

          if  pos('</H2></TD></TR>',lf)<>0 then
           begin    (* 2 *)
             numimg:=numimgmax;
             str(numimg,buf);
             insert('<tr><td>autres'+
                    ' travaux</td><td>nø</td><td>nom'+
                      '</td><td colspan='+
                       buf+
                        '>nombre d'+
                            #39+
                          'images</td><td>taille<'+
                            '/td><td>autres travaux<'+
                             '/td></tr>',
                                lf,
                              pos('</H2></TD></TR>',lf)+15);
             liste1^[x]:=lf;
           end;

           if  pos('</TABLE>',lf)<>0 then
           begin    (* 2 *)
              numimg:=numimgmax+5;
              str(numimg,buf);
             insert(' colspan='+buf,lf,pos('<tr><td>Occupation',lf)+8);
             liste1^[x]:=lf;
           end
      end;

     assign(f2,'basenw2.htm');
     rewrite(f2);
     for x:=0 to  n-1 do
     begin
     writeln(f2,liste1^[x]);
     end;
     close(f2);

     dispose(listea);
     dispose(liste2);
     dispose(liste1);
end.