YoannMorl Posted December 17, 2012 Share Posted December 17, 2012 (edited) Hi, I have an array filled with data from some ini files. A section of each ini files contain a key named "AU" and containing a date like "2012/12/14". Some files does not contain any value for "AU". I need to the date from each file with the date of today and store in a file each line of the array if the date of today is before the date in the file. This is what i've done for now : $aIni_List = _FileListToArray(@ScriptDir & "DB", "*.ini", 1) $aIni_Content = IniReadSection(@ScriptDir & "DB" & $aIni_List[1], "INFOS") Global $aResults[$aIni_List[0] + 1][$aIni_Content[0][0]] For $i = 1 To $aIni_Content[0][0] $aResults[0][$i - 1] = $aIni_Content[$i][0] Next For $i = 1 To $aIni_List[0] $aIni_Content = IniReadSection(@ScriptDir & "DB" & $aIni_List[$i], "INFOS") For $j = 1 To $aIni_Content[0][0] $aResults[$i][$j - 1] = $aIni_Content[$j][1] Next Next I don't know how to do ? Could you help me please ? Regards. Edited December 17, 2012 by YoannMorl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl, Do you have access to the original ini files? Do you have data from multiple ini files in this array, or is it from just the one? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 (edited) With the script above, i have in the array all data from all ini files. I can access to all ini files Edited December 17, 2012 by YoannMorl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl,I see you have now posted some code - always a good idea. More questions - as your explanation is none too clear. What do you mean by?I need to the date from each file with the date of todayAnd if you find an "AU" date that is later than today's date, what do you mean by?store in a file each line of the arrayPerhaps if you post an example of an ini file and explain which lines are affected it would help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 Sorry for my bad english. I'm french ^^ Each ini files contains a section called "INFOS" Each section on all files contain a key called "AU" with a value (or not) written like that : "2012/12/01" I need to do a report of each file with the date contained in "AU" is prior the today date. Ini files : [iNFOS] Key1=xxx Key2=xxx AU=2012/12/01 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl, This should get you started: #include <File.au3> #include <Date.au3> ; Get the list of ini files $aIni_List = _FileListToArray(@ScriptDir, "*.ini", 1) For $i = 1 To $aIni_List[0] ; See if a date value exists $sIni_Date = IniRead(@ScriptDir & "" & $aIni_List[$i], "INFOS", "AU", "Error") ConsoleWrite($sIni_Date & @CRLF) If $sIni_Date = "Error" Then ; Code for the case that there is no AU key/value pair <<<<<<<<<<<<<<<<<< Else $iDateDiff = _DateDiff("D", $sIni_Date, _NowCalc()) If $iDateDiff > 0 Then ; Code for the case that AU date is before today <<<<<<<<<<<<<<<<<< Else ; Code for the case that AU date is today or after <<<<<<<<<<<<<<<<<< EndIf EndIf Next M23 P.S. Si j'ai mal compris, envoie-moi un PM en francais. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 (edited) Merci. Voilà ce que j'ai pu faire : expandcollapse popupFunc _Retard() ; Get the list of ini files $aIni_List = _FileListToArray(@ScriptDir & "DB", "*.ini", 1) For $i = 1 To $aIni_List[0] ; See if a date value exists $sIni_Date = IniRead(@ScriptDir & "DB" & $aIni_List[$i], "INFOS", "AU", "Error") ConsoleWrite($sIni_Date & @CRLF) If $sIni_Date = "Error" Then $RetardStatus = "0" Else $iDateDiff = _DateDiff("D", $sIni_Date, _NowCalc()) If $iDateDiff > 0 Then $RetardStatus = "1" Else $RetardStatus = "2" EndIf EndIf Next If $RetardStatus = "0" Then MsgBox(0,"Debug","Toutes les ressources sont disponibles.") ElseIf $RetardStatus = "1" Then MsgBox(0,"Debug","Pas de ressources en retard") ElseIf $RetardStatus = "2" Then MsgBox(0,"Debug","Une ou plusieurs ressources sont en retard") Else MsgBox(0,"Debug","Erreur") EndIf EndFunc How i can do to store data from the current ini file (in error) in a file ? in fact, store each value from keys of the ini file corresponding to $RetardStatus = "2" Edited December 17, 2012 by YoannMorl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl,I said send me a PM in french - not to post in that language. We only use English in the forum. As to only getting notified about specific folders, take a look at this:expandcollapse popup#include <Array.au3> #include <File.au3> #include <Date.au3> _Retard() Func _Retard() ; Create an array to hold the files that meet the criterion Local $aRetard[1] = [0] Local $RetardStatus = 0 ; Get the list of ini files $aIni_List = _FileListToArray(@ScriptDir, "*.ini", 1) For $i = 1 To $aIni_List[0] ; See if a date value exists $sIni_Date = IniRead(@ScriptDir & "" & $aIni_List[$i], "INFOS", "AU", "Error") If $sIni_Date = "Error" Then ; Leave $RetardStatus unchanged Else ; Increase $RetardStatus $RetardStatus += 1 ; Check the date $iDateDiff = _DateDiff("D", $sIni_Date, _NowCalc()) If $iDateDiff > 0 Then ; Add the file to the array $aRetard[0] += 1 ReDim $aRetard[$aRetard[0] + 1] $aRetard[$aRetard[0]] = $aIni_List[$i] EndIf EndIf Next Switch $RetardStatus Case 0 MsgBox(0, "Debug", "Toutes les ressources sont disponibles.") Case Else Switch $aRetard[0] Case 0 MsgBox(0, "Debug", "Pas de ressources en retard") Case Else MsgBox(0, "Debug", "Une ou plusieurs ressources sont en retard") _ArrayDisplay($aRetard) EndSwitch EndSwitch EndFunc ;==>_RetardNow you get notified about out-of-date files with a nice array showing their names. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 (edited) Yep ^^ That's exactly what i need ^^ The _ArrayDisplay gave me a list of ini files. Is there a way to display value of keys for these ini files like "GRE", "NOM", "PRENOM", and "AU" in this array ? I've tried with IniRead but without success. For information, the final project is a tool for managing ressources reservation. Edited December 17, 2012 by YoannMorl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl,You need to change the code where you add the filename to the array. The array will need to be 2D so there is room for the additional data and you can fill these extra elements by using IniRead in the same way as you obtain the date. Give it a go yourself - you know where to find me if you get stuck. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 (edited) Ok 'ill try something and let you see. Thanks. i've done that, but only 1 line is added to RETARD.TXT, nothing more expandcollapse popupFunc _Retard() ; Create an array to hold the files that meet the criterion Local $aRetard[1] = [0] Local $RetardStatus = 0 ; Get the list of ini files $aIni_List = _FileListToArray(@ScriptDir & "DB", "*.ini", 1) For $i = 1 To $aIni_List[0] ; See if a date value exists $sIni_Date = IniRead(@ScriptDir & "DB" & $aIni_List[$i], "INFOS", "AU", "Error") If $sIni_Date = "Error" Then ; Leave $RetardStatus unchanged Else ; Increase $RetardStatus $RetardStatus += 1 ; Check the date $iDateDiff = _DateDiff("D", $sIni_Date, _NowCalc()) If $iDateDiff > 0 Then ; Add the file to the array $aRetard[0] += 1 ReDim $aRetard[$aRetard[0] + 1] $aRetard[$aRetard[0]] = $aIni_List[$i] $RetardGRE = IniRead(@ScriptDir & "DB" & $aIni_List[$i],"INFOS","GRE","ERROR") $RetardNOM = IniRead(@ScriptDir & "DB" & $aIni_List[$i],"INFOS","NOM","ERROR") $RetardPRE = IniRead(@ScriptDir & "DB" & $aIni_List[$i],"INFOS","PRENOM","ERROR") $RetardDAT = IniRead(@ScriptDir & "DB" & $aIni_List[$i],"INFOS","AU","ERROR") FileDelete(@ScriptDir & "RETARD.TXT") FileWriteLine(@ScriptDir & "RETARD.TXT","" & $RetardGRE & " - " & $RetardNOM & " " & $RetardPRE & " - " & $RetardDAT & "") EndIf EndIf Next Switch $RetardStatus Case 0 MsgBox(0, "Debug", "Toutes les ressources sont disponibles.") Case Else Switch $aRetard[0] Case 0 MsgBox(0, "Debug", "Pas de ressources en retard") Case Else MsgBox(0, "Debug", "Une ou plusieurs ressources sont en retard") ;~ _ArrayDisplay($aRetard) ShellExecute(@ScriptDir & "RETARD.TXT") EndSwitch EndSwitch EndFunc ;==>_Retard Edited December 17, 2012 by YoannMorl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl,Spot the difference: expandcollapse popup#include <Array.au3> #include <File.au3> #include <Date.au3> _Retard() Func _Retard() ; Create an array to hold the files that meet the criterion Local $aRetard[1] = [0] Local $RetardStatus = 0 ; Get the list of ini files $aIni_List = _FileListToArray(@ScriptDir, "*.ini", 1) ; Delete an existing file FileDelete(@ScriptDir & "RETARD.TXT") For $i = 1 To $aIni_List[0] ; See if a date value exists $sIni_Date = IniRead(@ScriptDir & "" & $aIni_List[$i], "INFOS", "AU", "Error") If $sIni_Date = "Error" Then ; Leave $RetardStatus unchanged Else ; Increase $RetardStatus $RetardStatus += 1 ; Check the date $iDateDiff = _DateDiff("D", $sIni_Date, _NowCalc()) If $iDateDiff > 0 Then ; Add the file to the array $aRetard[0] += 1 ReDim $aRetard[$aRetard[0] + 1] $aRetard[$aRetard[0]] = $aIni_List[$i] $RetardGRE = IniRead(@ScriptDir & "" & $aIni_List[$i], "INFOS", "GRE", "ERROR") $RetardNOM = IniRead(@ScriptDir & "" & $aIni_List[$i], "INFOS", "NOM", "ERROR") $RetardPRE = IniRead(@ScriptDir & "" & $aIni_List[$i], "INFOS", "PRENOM", "ERROR") $RetardDAT = $sIni_Date ; Add the data to the file FileWriteLine(@ScriptDir & "RETARD.TXT", "" & $RetardGRE & " - " & $RetardNOM & " " & $RetardPRE & " - " & $RetardDAT & "") EndIf EndIf Next Switch $RetardStatus Case 0 MsgBox(0, "Debug", "Toutes les ressources sont disponibles.") Case Else Switch $aRetard[0] Case 0 MsgBox(0, "Debug", "Pas de ressources en retard") Case Else MsgBox(0, "Debug", "Une ou plusieurs ressources sont en retard") ShellExecute(@ScriptDir & "RETARD.TXT") EndSwitch EndSwitch EndFunc ;==>_RetardAnswer:Delete the file before the loop. Good to go? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 Are you serious ? I've done this mistake ? Sorry ^^ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl,Are you serious ? I've done this mistake ?Just look at the code you posted! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
YoannMorl Posted December 17, 2012 Author Share Posted December 17, 2012 I think i can continue now. Thank you for your help and your patience. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 17, 2012 Moderators Share Posted December 17, 2012 YoannMorl, Il n'y a pas de quoi. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now