ant2ne Posted August 23, 2013 Share Posted August 23, 2013 I've got a program that outputs some data into a text file like so... 2013-08-22 finished successfully 2013-08-19 finished successfully 2013-08-18 finished successfully 2013-08-17 finished successfully 2013-08-16 finished successfully 2013-08-15 finished successfully Since it didn't report anything on the 20th and the 21st, I assume it failed. I'd like to fill in those missing lines with the appropriate dates and "failed", but I don't know how to decrement and stay in line with the dates since calendars aren't based on the 10 count. The day before the 1st might be a 30 a 31 28 etc. Is there a nifty date type function I can toss those dates into and have it spit out what I need? Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted August 23, 2013 Moderators Solution Share Posted August 23, 2013 ant2ne,No, but you can do it pretty easily like this: #include <Array.au3> #include <Date.au3> ; Use _FileReadToArray to get an array Local $aArray[] = [6, _ "2013-08-22 finished successfully", _ "2013-08-19 finished successfully", _ "2013-08-18 finished successfully", _ "2013-08-17 finished successfully", _ "2013-08-16 finished successfully", _ "2013-08-15 finished successfully"] ; Work up through array elements For $i = $aArray[0] To 2 Step -1 $sDate_1 = StringReplace(StringLeft($aArray[$i], 10), "-", "/") $sDate_2 = StringReplace(StringLeft($aArray[$i - 1], 10), "-", "/") ; Check dates are 1 day apart If _DateDiff("D", $sDate_1, $sDate_2) <> 1 Then ; If not then determine the missing date $sMissing_Date = StringReplace(_DateAdd("D", 1, $sDate_1), "/", "-") ; And add it to the array _ArrayInsert($aArray, $i, $sMissing_Date & " - failed") ; Reset the counter $i += 1 _ArrayDisplay($aArray) ; Just for display EndIf Next ; And then you rewrite this array with _FileWriteFromArray _ArrayDisplay($aArray, "Ended")All clear? 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...
ant2ne Posted August 26, 2013 Author Share Posted August 26, 2013 Awesome code thanks. With a little tweaking it works. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2013 Moderators Share Posted August 26, 2013 ant2ne,My pleasure. 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