abracadabraPDF › Forums › PDF – Général › Vérification › Répondre à : Vérification

bonjour,
Voici donc un script pour vérifier les indices de tes champs :
var reponse="";
while (!/^(\w+,*)+$/.test(reponse)) {
var reponse=app.response({
cQuestion: "Indiquez les différents noms de champs en les séparant par une virgule. Exemple :",
cTitle: "Vérification des indices de champs",
cDefault: "Verifier,Recommencer,Titre,Question,Q,R,Aide,cAc",
cLabel: "Champ(s) :"
});
}
if (reponse!=null) {
var reponse=reponse.replace(/[,]{2,}/g,",").replace(/^,/,"").replace(/,$/,"");
var aVerifier=reponse.split(",");
var lesSeries=[];
for (var i=0; i<this.numFields; i++) {
var nomChamp=this.getNthFieldName(i);
for (var j=0; j<aVerifier.length; j++) {
var RegExTest=new RegExp("^"+aVerifier[j]+"\\.(\\d+)\\.(\\d+)$");
var OK=nomChamp.match(RegExTest);
if (OK) {
var ind1=OK[1];
var ind2=OK[2];
if (lesSeries[j]==undefined) lesSeries[j]=[aVerifier[j],[]];
if (lesSeries[j][1][ind1]==undefined) lesSeries[j][1][ind1]=[ind1,[]];
if (lesSeries[j][1][ind1][1][ind2]==undefined) lesSeries[j][1][ind1][1][ind2]=[ind2];
break;
}
}
}
var txt=""
for (var ind=0; ind<lesSeries.length; ind++) {
if (lesSeries[ind]==undefined) txt+="Il n'y a pas de champ \""+aVerifier[ind]+"\" avec indices.\r";
else {
for (var j=1; j<lesSeries[ind][1].length; j++) {
if (lesSeries[ind][1][j]==undefined) txt+="Il n'y a pas d'indice de premier niveau \""+aVerifier[ind]+"."+[j]+"\".\r";
else {
for (var k=1; k<lesSeries[ind][1][j][1].length; k++) {
if (lesSeries[ind][1][j][1][k]==undefined) txt+="Il n'y a pas d'indice de second niveau \""+aVerifier[ind]+"."+[j]+"."+k+"\".\r";
}
}
}
}
}
if (!txt) txt="Tout est OK !!!";
console.clear();
console.show();
console.println(txt);
}
Ce script tient compte qu’il n’y a apparemment pas d’indices 0 pour tes champs. Je joint un fichier où le script regarde si il y a des indices 0.
@+
😎