nitro322 Posted June 19, 2006 Share Posted June 19, 2006 I just encountered an error in one of my scripts: Line 0 (File "Y:\windows\Packages\AutoFLAC\autoflac_11\AutoFLAC.exe"); $new = fileopen($ripdir & "\" & $meta & $album & ".cue", 2) Error: Unable to open file, the maximum number of open files has been exceeded. Now, I know the error message is rather self-explanatory, but I can't figure out where the problem lies. I have several fileopen() and filefindfirstfile() calls in my script, but I just did a manual search through the entire program and I seem to close every one of them as soon as I'm done with the file handle. Are there any other functions that require a fileclose()? Could this be that Windows itself can not open any additional files and it's not an issue with the script (unlikely, though, as I'm only running a couple other apps)? Any other ideas? The program had been running for quite some time before I got the error message, making many iterations through the main body, so the behavior seems consistant with a simple leak. Like I said, though, I can't find that issue: I have 5 fileopen()'s, 3 filefindfirstfile()'s, and 8 fileclose()'s. What am I missing? Thanks. I can complete the complete code if that'd help, but it's a pretty long script. http://www.legroom.net/ Link to comment Share on other sites More sharing options...
MHz Posted June 19, 2006 Share Posted June 19, 2006 Nitro322, Just attach the script and I'll do a quick check on your file handles and see if any are prone to be left open. Link to comment Share on other sites More sharing options...
nitro322 Posted June 19, 2006 Author Share Posted June 19, 2006 Here you go, MHz. I appreciate the assistance.AutoFLAC.au3 http://www.legroom.net/ Link to comment Share on other sites More sharing options...
MHz Posted June 19, 2006 Share Posted June 19, 2006 (edited) Something just spotted here. You use Return to exit the function before FileClose can close the handle. ; Function to search %path% for executable func SearchPath($file) ; Search DOS path directories $dir = stringsplit(envget("path"), ';') redim $dir[$dir[0]+1] $dir[$dir[0]] = @scriptdir for $i = 1 to $dir[0] $exefiles = filefindfirstfile($dir[$i] & "\*.exe") if $exefiles == -1 then continueloop $exename = filefindnextfile($exefiles) do if $exename = $file then return 1 <------------ Problem here with handle left open $exename = filefindnextfile($exefiles) until @error fileclose($exefiles) next Edited June 19, 2006 by MHz Link to comment Share on other sites More sharing options...
nitro322 Posted June 19, 2006 Author Share Posted June 19, 2006 Dang, missed that. Thanks for the help, MHz. http://www.legroom.net/ 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