sshrum Posted October 3, 2006 Share Posted October 3, 2006 (edited) This is my fileSearch function that uses a DOS return to get a list of files. I've run with this code without fail but I recently got a user that sez that my app is bombing on line 21: + $aFiles[$iLine] = $aLine[$i] ...to the effect of being out of the array range. I know this can't be the reason but his screenshots prove it. I have no idea what could be wrong. I've up'ed the array DIM to 100K and he still gets the error. Anyone have suggestions? Func _FileSearch($sQuery, $iSubdir=0) $iLine = 0 $sLine = "" $aLine = "" Dim $aFiles[100000] $aFiles[0] = 0 $sArguments = "/a-d /b /on";filenames, not folders If $iSubDir Then $sArguments = $sArguments & " /s" FileWriteLine($hLog, ' > (_FileSearch) CMDLINE: dir "' & $sQuery & '" ' & $sArguments) $aRaw = Run(@ComSpec & ' /c dir "' & $sQuery & '" ' & $sArguments, @SystemDir, @SW_HIDE, $STDOUT_CHILD) $iCount = 0 While 1 $sLine = StdoutRead($aRaw) If @error Then ExitLoop $aLine = StringSplit($SLine, @CRLF) If $aLine[0] > 1 Then For $i = 1 To $aLine[0] - 1 If $aLine[$i] = "" Then Continueloop $iLine = $iLine + 1 FileWriteLine($hLog, " " & $iLine & " = " & $aLine[$i] & @CRLF) $aFiles[$iLine] = $aLine[$i] Next ElseIf $aLine[0] = 1 Then $iLine = $iLine + 1 FileWriteLine($hLog, " " & $iLine & " = " & $aLine[1] & @CRLF) $aFiles[$iLine] = $sLine Else ExitLoop EndIf _Verbose("Processing directory..." & @CRLF & "'" & $sQuery & "'" & @CRLF & "Matches found: " & $iLine) Wend $aFiles[0] = $iLine FileWriteLine($hLog, " > (_FileSearch) Entries found: " & $aFiles[0] & @CRLF) ReDim $aFiles[$iLine + 1] Return $aFiles EndFunc TIA Edited October 3, 2006 by sshrum Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
FuryCell Posted October 3, 2006 Share Posted October 3, 2006 (edited) This UDF by Larry appears to provide the functionality you are looking for.Link Edited October 3, 2006 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
sshrum Posted October 3, 2006 Author Share Posted October 3, 2006 This UDF by Larry appears to provide the functionality you are looking for.LinkUnfortunatley, his is much slower than mine when dealing with large numbers of files (I was using this UDF before). My way is MUCH faster. Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
BitRot Posted October 3, 2006 Share Posted October 3, 2006 Anyone have suggestions?Display the "$iLine" -variable just before using it (into that "#sFiles"-array), and see what the last value is before it "bombs out". For some reason I have the idea your code gets into an endless loop somewhere.Allso : Write all the returned "StdoutRead($aRaw)" -lines into the log-file, and see what you get. 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