Jump to content

What is wrong with this?


Recommended Posts

I have 2 different paths, and I want to see (inside MsgBox) all files that are inside each path...

I tried:

#Include <File.au3>
#Include <Array.au3>

Global $paths_array [2]
$paths_array [0] = "C:\test\01"
$paths_array [1] = "C:\test\02"  

For $x = 0 To 1
    
    $file_list_array = _FileListToArray($paths_array[$x], "*.*")
    
    For $n = 1 To $file_list_array[0]
        
        $file = $paths_array[$x] & "\" & $file_list_array[$n]
        
        MsgBox(0, "", $file)
    Next

Next

What did I get? => I see (inside MsgBox) all files that are inside

$paths_array [0] = "C:\test\01"

but, when it would be supposed to look at

$paths_array [1] = "C:\test\02"

I get nothing but an error message:

CODE
12) : ==> Subscript used with non-Array variable.:

For $n = 1 To $file_list_array[0]

For $n = 1 To $file_list_array^ ERROR

How to correct this??

Thanks in advance.

Best regards.

MLMK - my blogging craziness...
Link to comment
Share on other sites

Hi,

Nothing I can see is wrong with your code providing the paths exist and the paths contain files.

Maybe ad an error check to see where it's going wrong.

#Include <File.au3>
#Include <Array.au3>

Global $paths_array [2]
$paths_array [0] = "C:\test\01"
$paths_array [1] = "C:\test\02" 

For $x = 0 To 1
    Local $file = ""
    $file_list_array = _FileListToArray($paths_array[$x], "*.*")
    If @error > 0 Then 
        MsgBox(0, "Error reading path " & $x + 1 & " to array", _
                    'The return for _FileListToArray($paths_array[$x], "*.*") Error Code: ' & @error & @LF & _
                    "Look at _FileListToArray() function in AutoIt help file for what this error code means.")
        ContinueLoop
    EndIf   
    For $n = 1 To $file_list_array[0]
        $file &= $paths_array[$x] & "\" & $file_list_array[$n] & @LF
    Next
    MsgBox(0, "Path " & $x + 1, $file)
Next

Cheers

Edit: typos and I forgot to say Hello :P

Edited by smashly
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...