aommaster Posted June 26, 2010 Share Posted June 26, 2010 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 More sharing options...
JohnOne Posted June 26, 2010 Share Posted June 26, 2010 _filelisttoarray("bgm/"& $folder, "*.mp3", 1) does not return an object, it returns an array. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Beege Posted June 26, 2010 Share Posted June 26, 2010 (edited) For In statment is for object collections.Ya scratch that.. Its for arrays too. Edited June 26, 2010 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
JohnOne Posted June 26, 2010 Share Posted June 26, 2010 (edited) hmmm sorry, you are supposed to be able to use that with an array, I just never have and dont know how. Edited June 26, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
picaxe Posted June 26, 2010 Share Posted June 26, 2010 (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 June 26, 2010 by picaxe Link to comment Share on other sites More sharing options...
aommaster Posted June 26, 2010 Author Share Posted June 26, 2010 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 Link to comment Share on other sites More sharing options...
picaxe Posted June 26, 2010 Share Posted June 26, 2010 (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 June 26, 2010 by picaxe Link to comment Share on other sites More sharing options...
aommaster Posted June 26, 2010 Author Share Posted June 26, 2010 Oh okay. Thanks picaxe Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now