kjcdude Posted July 18, 2008 Share Posted July 18, 2008 (edited) $waccountfldr = "C:\Program Files\World of Warcraft\WTF\Account\" $search2 = FileFindFirstFile($waccountfldr & "*.*") $dir1 = waccountfldr("23" & ":" & "06") MsgBox(0, "", $dir1) func waccountfldr($time) Do $waccountdir = FileFindNextFile($search2) $foldertime = FileGetTime($waccountfldr & $waccountdir, 0, 0) if @error Then MsgBox(0, "", $waccountdir) Else $ftime1 = $foldertime[3] & ":" & $foldertime[4] EndIf Until $time = $ftime1 FileClose($search2) Return $waccountdir EndFunc All im trying to do is find a folder with the corresponding modified hour and minute. This is just the base of the code and i'm having alot of trouble with filefindnextfile working as it should. It seems to always error out and return blank results when there are in fact results to be found. Filefindnextfile works when i run it alone without any time searches, but as soon as i add that in it has trouble producing results. Any help would be greatly appreciated. Thanks Edited July 18, 2008 by kjcdude Link to comment Share on other sites More sharing options...
therks Posted July 18, 2008 Share Posted July 18, 2008 (edited) Well first off, you should be @error checking the FileFindNextFile to know when it has reached the end of the directory listing. When I ran the code I got caught in an infinite loop of MsgBox's from your FileGetTime @error check, because it kept looking for a file that didn't exist. Second, you don't declare $ftime1 before the Do loop. This means that if there's an error on the first FileGetTime the variable doesn't exist when it hits Until to check it, so it will hard error out. Third, are you sure that you have a file with hour/minute of 23/06 in that folder? Have you done a simple dump test with FileGetTime? Something like this: Do $file = FileFindNextFile($search) If @error Then ExitLoop $time = FileGetTime($folder & $file, 0, 0) ConsoleWrite($time[3] & ':' & $time[4] & @LF) Until 0 That will give you all the file mod times, then you can look through that list to see if what you're looking for exists. Here's a minor edit of your code to make it "work" $waccountfldr = "C:\" $search2 = FileFindFirstFile($waccountfldr & "*.*") $dir1 = waccountfldr("23" & ":" & "06") MsgBox(0, "found", $dir1) Func waccountfldr($time) Local $foundfile = 'none', $ftime1 Do $waccountdir = FileFindNextFile($search2) If @error Then ExitLoop $foldertime = FileGetTime($waccountfldr & $waccountdir, 0, 0) If @error Then MsgBox(0, "err", $waccountdir) Else $ftime1 = $foldertime[3] & ":" & $foldertime[4] If $ftime1 = $time Then $foundfile = $waccountdir EndIf EndIf Until $time = $ftime1 FileClose($search2) Return $foundfile EndFunc ;==>waccountfldr *Edit: Didn't listen to myself and forgot to declare $ftime1 before the Do loop. Edited July 18, 2008 by Saunders My AutoIt Stuff | My Github 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