dooshorama Posted July 16, 2004 Share Posted July 16, 2004 this is a useful and somewhat popular method for iterations: FOR $a IN [a,b,c,d] (similar to DOS batch command), or.. FOREACH $a [a,b,c,d] (similar to tcl) they both do the same thing. changing variable $a for every element of the set. i'm trying to do something similar and can't find the v3 equivalant. is this available in v3 or do i have to hack my own function? Link to comment Share on other sites More sharing options...
Developers Jos Posted July 16, 2004 Developers Share Posted July 16, 2004 You probably want to StringSplit the string into an array and then do a for.. next loop. $Arr = StringSplit("a,b,c,d",",") For $x = 1 to $arr[0] msgbox(0,'test',$arr[$x]) next SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
therks Posted July 16, 2004 Share Posted July 16, 2004 That's a little different from his intention though.He's looking for something that would do this.$Arr = StringSplit("Silly Rabbit", " "); Foreach $Val in $Arr MsgBox(0, 'Array Value', $Val); EndForeachWhich would return:2SillyRabbitAt least, that's how I see it. I use Foreach a lot in PHP, it's really handy.But JdeB is right, it's easier to just go with a regular for loop. It would be different if AutoIt supported Associative arrays, then the For...In construct would be very handy. But otherwise your best bet is something like what JdeB posted. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
dooshorama Posted July 16, 2004 Author Share Posted July 16, 2004 that's similar to what i was thinking but it's a bit code-ugly since that stringsplit has to sit there everytime. functional though. 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