deef99 Posted October 27, 2009 Share Posted October 27, 2009 And I thought this was the simplest part of coding this script!Everything in this script works great...except it will not delete each file once it is done getting the array info. The problem area is towards the end of the code. I've tried putting it different places in the script and it just will not delete the files.Where am I going wrong??? #Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_outfile=G:\CMS_IBAuto\Monitor\SLMonitor.exe#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****#include "array.au3"#include "File.au3"#include "Date.au3"#include "String.au3"$iIndex = 0Dim $slDim $read$pday = ""$ptime = ""$y = ""$agent = ""$message = ""$message1 = ""$skill = 400$mcount = 0; Change DIR and process files just movedFileChangeDir("\\ardfiles01\common\CMS_IBAuto\Monitor");look for first occurance of a file$search = FileFindFirstFile("CMS*.acsup")While @HOUR > 5 While 1 ;look for additional files $file = FileFindNextFile($search) If @error Then ExitLoop $file1 = FileOpen($file, 0) $agent = StringRight($file, 13) $agent = StringLeft($agent, 7) $ptime = StringMid($file, 4, 8) $pday = StringLeft($ptime, 4) $pday = StringLeft($pday, 2) & "/" & StringRight($pday, 2) $ptime = StringRight($ptime, 4) $ptime = StringLeft($ptime, 2) & ":" & StringRight($ptime, 2)$read = _FileReadToArray("\\ardfiles01\common\CMS_IBAuto\Monitor\" & $file, $sl) While $skill <> 403 $iIndex = _ArraySearch($sl, $skill, 0, 0, 0, 1) If @error Then ExitLoop $iIndex = $iIndex + 1 $y = StringRight($sl[$iIndex], 2) If $y = "51" Then $y = "R1" ElseIf $y = "52" Then $y = "R2" EndIf If $mcount < 10 Then $message = $pday & " " & $ptime & " AGENT: " & $agent & " Skill: " & $skill & " Level: " & $y $message1 = $message & @LF & $message1 Else $message1 = $message & @LF $mcount = 0 EndIf $mcount = $mcount + 1 $skill = $skill + 1 SplashTextOn("SL Automate Monitor", $message1, 350, 190, 800, 75, 20, "", 10) Sleep(200) WEnd $skill = 400 FileClose($file) ; NONE OF THESE WORK!!!! FileDelete("\\ardfiles01\common\CMS_IBAuto\Monitor\" & $file) FileDelete("\\ardfiles01\common\CMS_IBAuto\Monitor" & $file) FileDelete($file) WEnd FileClose($search)WEnd Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 27, 2009 Share Posted October 27, 2009 FileClose() the handle in $file1, not the file name in $file. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2009 Moderators Share Posted October 27, 2009 deef99,You are mixing up $file and $file1. Try using the latter in your FileDelete lines. 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...
PsaltyDS Posted October 27, 2009 Share Posted October 27, 2009 (edited) deef99, You are mixing up $file and $file1. Try using the latter in your FileDelete lines. M23 Lots of things wrong with the usage: ; ... $file = FileFindNextFile($search) ; ... $file1 = FileOpen($file, 0) ; ... $read = _FileReadToArray("\\ardfiles01\common\CMS_IBAuto\Monitor\" & $file, $sl) ; ... FileClose($file) ; NONE OF THESE WORK!!!! FileDelete("\\ardfiles01\common\CMS_IBAuto\Monitor\" & $file) FileDelete("\\ardfiles01\common\CMS_IBAuto\Monitor" & $file) FileDelete($file) The variable $file is the string name, and $file1 is the handle from FileOpen(). _FileReadToArray() should have been done with the $file1 handle because it was already open. FileClose() should have been done with the $file1 handle. FileDelete() fails because the file is not closed yet. Lesson: Don't mix usage of a file handle and the string path of the same file. Edited October 27, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
deef99 Posted October 27, 2009 Author Share Posted October 27, 2009 Mannnnnnnnnnnnnnnnnnnnn!!!!!! I KNEW it was gonna be something pretty stupid. And look at you two - so kind about it. Hah, you made my day! Many thanks! D Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 27, 2009 Moderators Share Posted October 27, 2009 deef99, Could I suggest using identifiers for your variables along these lines (taken from the UDF rules): Variable Names The first set of characters after the dollar sign (“$”) should be used to specify the type of data that will be held in it. The following list signifies the different prefixes and their data type significance. $a<letter> - Array (the following letter describes the data type taken from the rest of the data types below) $b - Binary data $h - File or window handle $i - Integer $f - Boolean $n - Floating point number $s - String $v - Variant (unknown/variable type of data) The rest of the name uses capitalized words to describe the function of the variable. Names like “$iC” are unacceptable. "$aiWeekDayNames" or "$iCounter" are much preferable It really does help you a lot. 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