Jump to content

Recommended Posts

Posted

Below are two snippets of code, both of which (I believe) should achieve the same thing.

#Include <File.au3>
#include <array.au3>

$folderarray = _FileListToArray("bgm/", "*", 2)
for $folder in $folderarray
    $filelist = _filelisttoarray("bgm/"& $folder, "*.mp3", 1)
    
    for $i=1 to ubound($filelist)-1
        msgbox(0,0, $fileitem)
    Next
Next

And this is the other:

#Include <File.au3>
#include <array.au3>

$folderarray = _FileListToArray("bgm/", "*", 2)
for $folder in $folderarray
    $filelist = _filelisttoarray("bgm/"& $folder, "*.mp3", 1)
    
    for $fileitem in $filelist
        msgbox(0,0, $fileitem)
    Next
Next

However, the second snippet doesn't work. Autoit gives me an error:

Variable must be of type "Object"

for the second nested For..in loop.

What is the reason for this?

Posted (edited)

For In statment is for object collections.

Ya scratch that.. Its for arrays too.

Edited by Beege
Posted (edited)

However, the second snippet doesn't work. Autoit gives me an error:

Variable must be of type "Object"

for the second nested For..in loop.

What is the reason for this?

You can read but not update/create an array inside a For In Next statement. Edited by picaxe
Posted

You can read but not update/create an array inside a For In Next statement.

Oh, I see. So I'm assuming I can't have this line in the for..in loop?

$filelist = _filelisttoarray("bgm/"& $folder, "*.mp3", 1)

Thanks

Posted (edited)

The problem is reusing the array $filelist in a For In Next statement, because of the read only limitation. Whereas For To Next is Ok.

Edited by picaxe

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
  • Recently Browsing   0 members

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