MrSergey Posted May 22, 2009 Share Posted May 22, 2009 Simple codeFor $i = 1 to 10NextMsgBox(0,"",$i)Result = 11Why? Link to comment Share on other sites More sharing options...
monoceres Posted May 22, 2009 Share Posted May 22, 2009 Simple. The loop executes while $i is less or not equal to 10. Therefor it doesn't quit until $i=11 (however the code inside the loop doesn't get executed when $i=11). Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 22, 2009 Share Posted May 22, 2009 Simple code Result = 11 Why? Simple. The loop executes while $i is less or not equal to 10. Therefor it doesn't quit until $i=11 (however the code inside the loop doesn't get executed when $i=11). Consider the following further examples: For $i = 1 To 10 ConsoleWrite("Inside For/Next loop: $i = " & $i & @LF) Next ConsoleWrite("After For/Next loop: $i = " & $i & @LF & @LF) $i = 0 Do $i += 1 ConsoleWrite("Inside Do/Until loop: $i = " & $i & @LF) Until $i = 10 ConsoleWrite("After Do/Until loop: $i = " & $i & @LF & @LF) $i = 0 While 1 $i += 1 ConsoleWrite("Inside While/WEnd loop: $i = " & $i & @LF) If $i >= 10 Then ExitLoop WEnd ConsoleWrite("After While/WEnd loop: $i = " & $i & @LF & @LF) Note you could add "If $i >= 10 Then ExitLoop" to the bottom of the For/Next loop also and get execution on $i = 10, and it will still be 10 after the loop. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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