Je rencontre *de nouveau* un problème : j'ai avancé sur mes briques de programme pour l'exploitation de fichiers plats (voir mon précédent topic ici), et je me suis rendu compte que le parcours d'un fichier tel que je le fais est très long. Voici mon code :
► Afficher le texte
Code : Tout sélectionner
; *************************************************************
; * INTERFACAGE DE FICHIER PLAT - ECRIT PAR GHOST LINE - 2009 *
; *************************************************************
#include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -------------------------------------------------------------
; * DECLARATION DES VARIABLES *
; -------------------------------------------------------------
$chemin_entree = "m:\timeless\orli\recu\bck\"
;$chemin_entree = "c:\"
$i = 1
$j = 1
$z = 0
$y = 0
$recherche = "1163" ; Pourrait tout aussi bien être un n° de commande, ou tout autre chose
$date_debut = "20090810"
$date_fin = "20090810"
$type_fichier = "*.paq"
$exemple_commentaire = "1163"
$exemple_stock = ""
Local $array_fichiers_ok[1]
Local $array_fichiers_ok_recherche[1]
; -------------------------------------------------------------
; * PROGRAMME *
; -------------------------------------------------------------
; * BLOC SELECTION DES FICHIERS ELIGIBLES
$liste_fichiers = _FileListToArray($chemin_entree, $type_fichier,0)
; * BLOC RECHERCHE FICHIER PAR DATE DE CREATION
$nombre_lignes_fichier = 0
For $z = 1 to $liste_fichiers[0]
$Date_creation = StringLeft(FileGetTime($chemin_entree&$liste_fichiers[$z],1,1),8)
if $Date_creation >= $date_debut Then
if $Date_creation <= $date_fin Then
$nombre_lignes_fichier = $nombre_lignes_fichier + 1
_ArrayAdd($array_fichiers_ok, $chemin_entree&$liste_fichiers[$z])
EndIf
else
EndIf
Next
; * BLOC RECHERCHE DANS UN FICHIER
$nombre_lignes_fichier_ok = 0
For $y= 1 to $nombre_lignes_fichier
If _ReplaceStringInFile($array_fichiers_ok[$y], $recherche, $recherche) Then
_ArrayAdd($array_fichiers_ok_recherche, $array_fichiers_ok[$y])
$nombre_lignes_fichier_ok = $nombre_lignes_fichier_ok + 1
EndIf
Next
If $nombre_lignes_fichier_ok = 0 Then
MsgBox (0,"","Aucun fichier trouvé avec ces critères")
Else
MsgBox(0,"", $nombre_lignes_fichier_ok&" fichier(s) trouvés remplissant ces critères")
EndIf
; BARRE DE PROGRESSION DU PARCOURS DES FICHIERS
; * BLOC LECTURE : ON STOCKE LES RESULTATS CORRESPONDANTS D'UN FICHIER DANS UNE ARRAY
$fichier_entree = $array_fichiers_ok[1]
$CountLines = _FileCountLines($fichier_entree)
Dim $array[$CountLines-1][6]
$fichier_a_traiter = FileOpen($fichier_entree,0)
While 1
$ligne = FileReadLine($fichier_a_traiter,$i+1)
If @error = -1 Then ExitLoop ; code erreur de FileReadLine : on arrive a la fin du fichier ? on quitte la boucle
$num_commande = StringStripWS(StringMid($ligne,7,9),2)
$recept_caisse = StringStripWS(StringMid($ligne,41,5),2)
$commentaire = StringStripWS(StringMid($ligne,54,20),2)
$quantite = StringStripWS(StringMid($ligne,90,10),2)
$date_exped = StringStripWS(StringMid($ligne,115,8),2)
$stock_dest = StringStripWS(StringMid($ligne,154,5),2)
Select
Case $exemple_commentaire <> ""
If $exemple_commentaire = $commentaire Then
$array[$j-1] [0] = $num_commande
$array[$j-1] [1] = $recept_caisse
$array[$j-1] [2] = $commentaire
$array[$j-1] [3] = $quantite
$array[$j-1] [4] = $date_exped
$array[$j-1] [5] = $stock_dest
$j = $j + 1
EndIf
Case $exemple_stock <> ""
If $exemple_stock = $stock_dest Then
$array[$j-1] [0] = $num_commande
$array[$j-1] [1] = $recept_caisse
$array[$j-1] [2] = $commentaire
$array[$j-1] [3] = $quantite
$array[$j-1] [4] = $date_exped
$array[$j-1] [5] = $stock_dest
$j = $j + 1
EndIf
EndSelect
$i=$i+1
WEnd
_ArrayDisplay($array)
;~ ; * BLOC GUI *
;~ $Form1 = GUICreate("Recherche commandes Albi", 559, 351, 231, 156)
;~ $Group1 = GUICtrlCreateGroup(" Listes des commandes ", 8, 0, 193, 257)
;~ $List1 = GUICtrlCreateList("", 16, 16, 177, 227)
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
;~ $Group2 = GUICtrlCreateGroup(" Critères de recherche ", 208, 0, 257, 257)
;~ $Checkbox1 = GUICtrlCreateCheckbox("Entre le", 216, 24, 57, 17)
;~ $Checkbox2 = GUICtrlCreateCheckbox("Code stock magasin :", 216, 104, 121, 17)
;~ $Checkbox3 = GUICtrlCreateCheckbox("Recherche sur le commentaire :", 216, 168, 177, 17)
;~ $Label1 = GUICtrlCreateLabel("et le", 240, 48, 24, 17)
;~ $stock_mag = GUICtrlCreateInput("", 344, 104, 73, 21)
;~ $rech_com = GUICtrlCreateInput("", 216, 192, 233, 21)
;~ $datedebut = GUICtrlCreateDate("2009/08/06 15:45:28", 272, 24, 186, 21)
;~ $datefin = GUICtrlCreateDate("2009/08/06 15:45:48", 272, 48, 186, 21)
;~ GUICtrlCreateGroup("", -99, -99, 1, 1)
;~ $reinit = GUICtrlCreateButton("Réinitialiser", 472, 8, 81, 33, $WS_GROUP)
;~ $rechercher = GUICtrlCreateButton("Rechercher", 472, 48, 81, 33, $WS_GROUP)
;~ $quitter = GUICtrlCreateButton("Quitter", 472, 264, 81, 81, $WS_GROUP)
;~ $sortie = GUICtrlCreateEdit("", 8, 264, 457, 81)
;~ GUICtrlSetData(-1, "")
;~ GUICtrlSetCursor (-1, 2)
;~ GUISetState(@SW_SHOW)
;~ While 1
;~ $nMsg = GUIGetMsg()
;~ Switch $nMsg
;~ Case $GUI_EVENT_CLOSE, $quitter
;~ Exit
;~ EndSwitch
;~ WEnd
Merci d'avance de votre aide !



