Jump to content
Sign in to follow this  

for every [a,b,c,d]

Recommended Posts


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?


Share this post

Link to post
Share on other sites

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]

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

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);

Which would return:




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

Share this post

Link to post
Share on other sites
:( 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. :ph34r:

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.