Naviguation dans :  Perl  JavaScript  Détail  - load.cgi?Appel=extractUser
 présentée :  par cas d'appel   par traitements 
Retour à l'accueil
  
 
 Requêtes 

 load – User 

 fromDBase 

Requêtes de Ça-déménage.com
Accès particulier
Extrait des enregistrements
 loadUser | baseUser | identUser | saveUser | extractUser | contactUser | histoUser 


 extractUser  Extrait des enregistrements — Extraire des données
Syntaxe fromDBase(To,OUT,date,noms,From)
Paramètres 
nom  type  Description 
To  IN Cas d'appel
OUT  OUT Enregistrements retournés
Perl : scalaire passé par référence – JavaScript : tableau à 1 élément
date  IN Date de clôture de la base (éventuellement vide)
noms  IN Identifiant d'appel
From  IN Cas d'appel
retourne  OUT  0 : Traitement correct
non nul : Erreur de traitement
Fonctions util. 
 wsFile Fonction d'accès aux fichiers


Code Perl 


sub fromDBase {local($To,$OUT,$date,$noms,$From) = @_; 
 local $In = ''; if (&wsFile("read",$To,$noms,(($From ne "")?"Res":""),\$In)!=0) {return 100}; local $x = $In; 
 local($k,$x0,$y,$nom,$x1,$x2); 
 local %T0 = (); 
while(true) {
 if ($x ne "") {$x =~ s/^\s*//};
 if ($x eq '') {last}; $k = index($x,"/#T)");
 if ($k==-1) {return 101}; $k = $k+4; $x0 = substr($x,0,$k); $x = substr($x,$k);
 if ($x0!~/\(#T\((\w+)\)new:\/\/(\w+)\/#T\(.{3}Owner\):(\w+)\/#T\(.{3}Error\):(\w+)\/#T/) {next};
 $y = $1;
 if ($date ne "") {if ($2 gt $date) {next}};
 $nom = $3;
if ($From ne "") {
 $x1 = $4;
 if ($y eq "Resume") {if ($nom eq "1000") {next}} else {if ($From ne "Admin") {next}};
 if ($y eq "Contact") {if ($x0!~/\/#T\(ctcAdmin\):(\w+)\/#T/) {next}; $y .= $1};
 if ($nom eq "1000") {$nom = $noms};
 if ($x1 eq "1") {$x2 = "ws".$nom; if (defined %{$T0{$x2}}) {$T0{$x2}{$y} = ""}; next};
} else {
 if ($y eq "Contact") {if ($x0!~/\/#T\(ctcAdmin\):(\w+)\/#T/) {next}; $y .= $1};
 if ($nom eq "1000") {$nom = $noms} elsif ($nom ne $noms) {next};
}
 $x2 = "ws".$nom; if (!(defined %{$T0{$x2}})) {%{$T0{$x2}} = ()}; $T0{$x2}{$y} = $x0; $T0{$x2}{$y} =~ s/Owner\):1000\/#T/Owner\):$nom\/#T/;
}
 $x = ""; foreach $x2 (keys %T0) {foreach $y (keys %{$T0{$x2}}) {$x .= $T0{$x2}{$y}}}
 $$OUT = $x;
 return 0;
}
Code JavaScript 


function fromDBase(To,OUT,date,noms,From) { 
 var In = Array(''); if (wsFile("read",To,noms,((From!="")?"Res":""),In)!=0) {return 100}; var x = In[0]; 
 var k,x0,y,nom,x1,x2; 
 var T0 = []; 
while(true) {
 if (x!="") {x = x.replace(/^\s*/,"")};
 if (x=='') {break}; k = x.indexOf("/#T)");
 if (k==-1) {return 101}; k = k+4; x0 = x.substr(0,k); x = x.substr(k);
 if (!x0.match(/\(#T\((\w+)\)new:\/\/(\w+)\/#T\(.{3}Owner\):(\w+)\/#T\(.{3}Error\):(\w+)\/#T/)) {continue};
 y = RegExp.$1;
 if (date!="") {if (RegExp.$2>date) {continue}};
 nom = RegExp.$3;
if (From!="") {
 x1 = RegExp.$4;
 if (y=="Resume") {if (nom=="1000") {continue}} else {if (From!="Admin") {continue}};
 if (y=="Contact") {if (!x0.match(/\/#T\(ctcAdmin\):(\w+)\/#T/)) {continue}; y += RegExp.$1};
 if (nom=="1000") {nom = noms};
 if (x1=="1") {x2 = "ws"+nom; if (typeof(T0[x2])!="undefined") {T0[x2][y] = ""}; continue};
} else {
 if (y=="Contact") {if (!x0.match(/\/#T\(ctcAdmin\):(\w+)\/#T/)) {continue}; y += RegExp.$1};
 if (nom=="1000") {nom = noms} else if (nom!=noms) {continue};
}
 x2 = "ws"+nom; if (typeof(T0[x2])=="undefined") {T0[x2] = []}; T0[x2][y] = x0.replace(/Owner\):1000\/#T/,"Owner\):"+nom+"\/#T");
}
 x = ""; for(x2 in T0) {for(y in T0[x2]) {x += T0[x2][y]}}
 OUT[0] = x;
 return 0;
}