Jump to content

Two snippets, one works and one doesn't


Recommended Posts

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?

Link to comment
Share on other sites

For In statment is for object collections.

Ya scratch that.. Its for arrays too.

Edited by Beege
Link to comment
Share on other sites

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
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...