Jump to content

Why in the world am I getting this error?


Recommended Posts

Func _DirFileInfo($sBaseDir, ByRef $aMain)
;$aMain[File Number][0 = File Path, 1 = File Size]
    
    Dim $temp6[3]
    $temp6[0]=0
    $temp6[1]=1
    $temp6[2]=2
    $temp6 = DirGetSize($sBaseDir, 1)
    $iCount = $temp6[1] + $temp6[2]
    Local $hSearch = FileFindFirstFile($sBaseDir & "\*")
    Local $sFilePath, $iUBound = UBound($aMain, 1)
    
    For $i = 1 To $iCount
        $sFilePath = FileFindNextFile($hSearch)
        If StringInStr(FileGetAttrib($sBaseDir & "\" & $sFilePath), "D") == 0  Then; It's a file!
            ReDim $aMain[$iUBound+1][2]
            $aMain[$iUBound][0] = $sFilePath
            $aMain[$iUBound][1] = FileGetSize($sFilePath)
        Else;It's a folder!
            _DirFileInfo($sFilePath, $aMain)
        EndIf
    Next
EndFunc

Local $array[1][1]
_DirFileInfo("C:\Install Files", $array)
_ArrayDisplay($array)

Why in the world am I getting a "subscript used with non-array variable" error here? Why is it that _ArrayDisplay can display temp6 as an array, but AutoIT does not recognize it as an array? I am thoroughly confused. Shouldn't DirGetSize return an array?

Edited by Decker87
Link to comment
Share on other sites

Why in the world am I getting a "subscript used with non-array variable" error here? Why is it that _ArrayDisplay can display temp6 as an array, but AutoIT does not recognize it as an array? I am thoroughly confused. Shouldn't DirGetSize return an array?

Try to check DirGetSize function return value:

$temp6 = DirGetSize($sBaseDir, 1)
If @error Then Return SetError(1, 0, 0)
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...