Simpel Posted August 6, 2012 Share Posted August 6, 2012 (edited) Hello, I'm searching and searching but can't find the solution. I wan't to make a for next loop like this: $p = 0 For $n = 1 To 5 MsgBox(4096, "", $p) If $p = 0 Then MsgBox(4096, "", "IF") $p = 1 Else MsgBox(4096, "", "ELSE") $p = 0 EndIf Next AU3Check meansin line 2 REF: missing Nextin line 6 ERROR: missing next / ERROR: syntax error Is there no way to have a "If Then Else" loop inside a "For Next" loop? Regards, Simpel Edited September 25, 2015 by Simpel solved SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
Spiff59 Posted August 6, 2012 Share Posted August 6, 2012 (edited) If you put an action on the end of an If/Then statement it terminates the If/Then statement, making it a single-line If/Then and any following Else or EndIf is not treated as part of that If/Then statement. Just move the Msgbox() down to a separate line beneath the If/Then, leaving the If/then statement ending with the word "Then" Edit: PS - Welcome to the forum! Edited August 6, 2012 by Spiff59 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2012 Moderators Share Posted August 6, 2012 (edited) Hi, Simpel, welcome to the forum. You need to fix your If/Then lines. Take a look at this to see the difference.: $p = 0 For $n = 1 To 5 MsgBox(4096, "", $p) If $p = 0 Then MsgBox(4096, "", "IF") $p = 1 Else MsgBox(4096, "", "ELSE") $p = 0 EndIf Next Edit: Man I am slow today Edited August 6, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Simpel Posted August 6, 2012 Author Share Posted August 6, 2012 It's just as simpel as that. Thanks for the very fast help. Regards, Simpel SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 6, 2012 Moderators Share Posted August 6, 2012 Glad to be of help "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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