laurin1 Posted June 19, 2008 Share Posted June 19, 2008 I've not used for in much in AutoIt, but can For In be used with complex arrays? I am trying to simply iterate through an array like this $a[0][0] = 'testname' $a[0][1] = 'testnum' and AutoIt seems to just ignore it. Keith Davis MCSA, ZCE, A+, N+ http://www.laurinkeithdavis.com Link to comment Share on other sites More sharing options...
SadBunny Posted June 19, 2008 Share Posted June 19, 2008 If you would iterate through a 2-dim array, it wouldn't be sure in what order you want to iterate through it. You could simulate it though by making a function for reading a 2-dim array into a 1-dim array (for the lines) with 1-dim arrays (the line's contents per line) stored in it's elements, and iterate through the line arrays, line by line, and call that _ForIn2DArray($2dArray,$functionToCallPerElement) or something. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Kerros Posted June 19, 2008 Share Posted June 19, 2008 Do you have an example of what's not working for you? Much easier to debug if we can see what your are trying to do. Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
SadBunny Posted June 19, 2008 Share Posted June 19, 2008 Do you have an example of what's not working for you? Much easier to debug if we can see what your are trying to do. If you do exactly what he says he does, like the following, you'll see that you don't get a msgbox though you might expect one. Dim $a[2][2] $a[0][0]=1 $a[1][0]=2 $a[0][1]=3 $a[1][1]=4 For $x In $a MsgBox(0,0,0) Next Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
laurin1 Posted June 19, 2008 Author Share Posted June 19, 2008 (edited) AutoIt just ignores it, like it doesn't exist. In PHP I can write the code either way: $a[0][0] = 1a $a[0][1] = 1b $a[1][0] = 2a $a[1][1] = 2b foreach($a as $s){ echo $a[0].$a[1].'<br />'; } results: 1a1b 2a2b OR foreach($a as $s){ foreach($s as $x){ echo $x; } echo '<br >'; } results: 1a1b 2a2b AutoIt appears to just ignore the for in statement on multi arrays. Edited June 19, 2008 by laurin1 Keith Davis MCSA, ZCE, A+, N+ http://www.laurinkeithdavis.com Link to comment Share on other sites More sharing options...
Kerros Posted June 19, 2008 Share Posted June 19, 2008 Poor mans loop.... Local $a[2][2] $a[0][0] = '1a' $a[0][1] = '1b' $a[1][0] = '2a' $a[1][1] = '2b' $string = "" FOR $i= 0 To UBound($a)-1 $k = 0 $string = $string & $a[$i][$k] & @CRLF $k +=1 $string = $string & $a[$i][$k] & @CRLF NEXT Msgbox(0,'Test',$string) not elegant, but may work for you Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
laurin1 Posted June 19, 2008 Author Share Posted June 19, 2008 So the answer to my question is no, AutoIt does not do For In for multi arrays? Keith Davis MCSA, ZCE, A+, N+ http://www.laurinkeithdavis.com Link to comment Share on other sites More sharing options...
luzif3r Posted June 19, 2008 Share Posted June 19, 2008 as far as i can tell, no it does not work. you have to loop manually to UBound($array). there might be a function for this around allready. good luck. 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