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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
| '**********************************************************************
'* *
'* Lecture du fichier des series *
'* *
'**********************************************************************
'-------------------------------------------------------------------------------------------------------------------------------
'lecture_serie() -------- Fonction principale
'ouverture_fichier() ---- Gestion de l'ouverture du fichier
'verif() ---------------- Verification de l'integrité du fichier texte
'destruction_fichier() ---- Suppression du fichier texte
'-------------------------------------------------------------------------------------------------------------------------------
'********************************************************
'* *
'* FONCTIONS PRINCIPALES *
'* LECTURE_SERIE *
'* *
'********************************************************
sub lecture_serie()
' ------------------- DECLARATIONS -------------------
'Variables de travail de recupération de données
dim iPointvirgule as Integer;
dim sTampon as str;
dim sPv as str;
'Variables necessaires aux boucles
dim sTableau[40][40] as str;
dim iIndex as integer;
dim iIndexss as integer;
dim sFindeligne as str;
dim iFdl as integer;
dim iIndex_ligne as integer;
'Variables de test
dim iResultfeof as integer;
dim iResultatverification as integer;
' ------------------- PROGRAMME -------------------
'Ouverture du fichier
ouverture_fichier();
'Initialisation
iIndex=0;
sPv=";";
sTampon="0";
iIndexss=0;
sFindeligne="#";
iFdl=1;
iResultfeof=0;
' Verification de l'integrite du fichier
iResultatverification=verif();
if (iResultatverification==0) then
Print(" Presence du dollar!");
'-----Boucle incrementant les series
FSEEK("t:\\series\\serie.txt", 0,0);
Print(" Debut de l'acquisition des lignes...");
WHILE (iResultfeof==0)
iFdl=1;
iIndexss=0;
'-----Boucle incrémentant les sous series
While (iFdl!=0 && iResultfeof==0)
'-----Boucle incrémentant les champs d'une sous serie
iPointvirgule=1;
sTampon="0";
WHILE (iPointvirgule!=0 && iFdl!=0 && iResultfeof==0)
if (iFdl!=0) then
sTableau[iIndex][iIndexss]=ADDSTRING(sTableau[iIndex][iIndexss],sTampon);
end if
sTampon=FGETC("t:\\series\\serie.txt");
iResultfeof=FEOF("t:\\series\\serie.txt"); 'Test de fin fichier
iPointvirgule = CmpString(sTampon, sPv);
iFdl = CmpString(sTampon, sFindeligne);
WEND
iIndexss=iIndexss+1;
WEND
iIndex=iIndex+1;
iResultfeof=FEOF("t:\\series\\serie.txt");
WEND
Print(" Acquisition des lignes terminees!");
else
Print("! ! ! PAS DE DOLLAR, fichier non termine ! ! !");
end if
'Envoi du nombre de ligne a l'automate
UF.PROG.TAMPON.NBRE_DE_LIGNE=sval(toc(iIndex));
' Envoi de la ligne demandée a l'automate
iIndex_ligne=toi(UF.PROG.TAMPON.INDEX);
print("Envoi vers l'automate de la ligne Numero: ",iIndex_ligne," ...");
'Serie
'test sur jour
print("Ancienne valeur de la variable jour: ",UF.PROG.TAMPON.JOUR);
Print("(avant)Tableau jour ", sTableau[iIndex_ligne][0]);
UF.PROG.TAMPON.JOUR=SVAL(sTableau[iIndex_ligne][0]);
Print("(apres)Tableau jour ", sTableau[iIndex_ligne][0]);
print("Nouvelle valeur de la variable jour: ",UF.PROG.TAMPON.JOUR);
'fin du test
UF.PROG.TAMPON.SERIE=SVAL(sTableau[iIndex_ligne][1]);
Print("Tableau serie ", sTableau[iIndex_ligne][1]);
print("Nouvelle valeur de la variable serie: ",UF.PROG.TAMPON.SERIE);
UF.PROG.TAMPON.SOUS_SERIE=SVAL(sTableau[iIndex_ligne][2]);
UF.PROG.TAMPON.NATURE=SVAL(sTableau[iIndex_ligne][3]);
UF.PROG.TAMPON.COULEUR=SVAL(sTableau[iIndex_ligne][4]);
UF.PROG.TAMPON.GRAMMAGE_GCS=SVAL(sTableau[iIndex_ligne][5]);
UF.PROG.TAMPON.GRAMMAGE_GCI=SVAL(sTableau[iIndex_ligne][6]);
UF.PROG.TAMPON.GRAMMAGE_RI=SVAL(sTableau[iIndex_ligne][7]);
UF.PROG.TAMPON.GRAMMAGE_RS=SVAL(sTableau[iIndex_ligne][8]);
UF.PROG.TAMPON.CSG_COUPEUR_INF=SVAL(sTableau[iIndex_ligne][9]);
UF.PROG.TAMPON.CSG_COUPEUR_SUP=SVAL(sTableau[iIndex_ligne][10]);
UF.PROG.TAMPON.VANNE_RESINE_INF=SVAL(sTableau[iIndex_ligne][11]);
UF.PROG.TAMPON.VANNE_RESINE_SUP=SVAL(sTableau[iIndex_ligne][12]);
UF.PROG.TAMPON.LARGEUR_MOULEE=SVAL(sTableau[iIndex_ligne][13]);
UF.PROG.TAMPON.LARGEUR_FINIE=SVAL(sTableau[iIndex_ligne][14]);
UF.PROG.TAMPON.LONGUEUR=SVAL(sTableau[iIndex_ligne][15]);
UF.PROG.TAMPON.NBRE_PNX=SVAL(sTableau[iIndex_ligne][16]);
print("Transfert vers l'automate terminee!");
fclose("t:\\series\\serie.txt");
end sub
'********************************************************
'* *
'* FONCTIONS COMPLEMENTAIRES *
'* *
'********************************************************
' ----------------- Ouverture du fichier -----------------
sub ouverture_fichier()
dim iResult_fopen as integer;
iResult_fopen=0;
print("Demande d'ouverture du fichier texte...");
WHILE(iResult_fopen == 0)
iResult_fopen=fopen("t:\\series\\serie.txt","r+");
print("Tentative d'ouverture du fichier texte...");
WEND
print("Ouverture du fichier reussie!");
FSEEK("t:\\series\\serie.txt", 0,0);
end sub
' ----------------- Lecture de la clé de fin de programme -----------------
sub verif()
dim sDollar as str;
dim iResult as integer;
FSEEK("t:\\series\\serie.txt", -1,2);
sDollar=fgetc("t:\\series\\serie.txt");
iResult = CmpString(sDollar, "$");
print("Resultat du test de la presence d'un $: ",iResult, " (0 si OK)");
return iResult;
end sub
' ----------------- Suppression du fichier "Serie.txt" -----------------
sub destruction_fichier()
IF (UNLINK("t:\\series\\serie.txt")==1) THEN
PRINT ("Le fichier a ete supprime ! ! !");
END IF
end sub |
Partager