Morthawt Posted November 29, 2012 Share Posted November 29, 2012 (edited) I use for loops all the time ( For $a = 1 To $blah ) etc but I don't know what all the "For something in something" means or how it is used. I have seen examples but it makes no sense to me currently. Could you explain the principle and offer a short and simple example? Edited November 29, 2012 by Morthawt Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. Link to comment Share on other sites More sharing options...
JohnOne Posted November 29, 2012 Share Posted November 29, 2012 It's the same as looping through an array with for to next. But it cannot work with multidimensional arrays, and can work with objects. Search "For...In...Next" in help file it has examples of both arrays and objects. 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...
jmon Posted November 29, 2012 Share Posted November 29, 2012 The difference is that in a For .. To loop, you go through the index and in a For .. In loop you go through the data contained in the array. Check out this example, you will understand: Global $aArray[5] = ["Value 1", _ "Value 2", _ "Another Value", _ "And another", _ "Last one"] ;For .. in For $TheValue In $aArray ConsoleWrite($TheValue & @CRLF) Next ;For $i = ... to For $i = 0 To UBound($aArray) -1 ConsoleWrite($aArray[$i] & @CRLF) Next You can see that in the For .. In loop, $TheValue is automatically assigned to the actual value of the array. It loops incrementally until the end of the array. I hope it's clear enough. [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center] Link to comment Share on other sites More sharing options...
Morthawt Posted November 30, 2012 Author Share Posted November 30, 2012 Ah perfect! Thanks. I understand now. I have just avoided that because it did not make sense, until now. Thanks Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials. 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