Jump to content

Recommended Posts

Posted (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 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'

 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...