Sign in to follow this  
Followers 0
Decker87

Why in the world am I getting this error?

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Your $count variable is 3 ($temp6[1] + $temp6[2])... There is no $temp6[3], it's out of the array bounds. your array only has $temp6[0], $temp6[1], $temp6[2]... 3 items.


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0