BrokenDynasty Posted July 5, 2004 Share Posted July 5, 2004 I have a 300 or so line script with a tangle of If/Else statements. I would like some of the Else's to instruct the script to start over again, how can I do this in the most simple way? Thanks in advance. Link to comment Share on other sites More sharing options...
pekster Posted July 5, 2004 Share Posted July 5, 2004 Put it in a loop and cycle the loop for those statements you want to start over. Once you get out of your conditinal testing block, exit the loop. Example: While 1 $number = InputBox("Input A Number", "Enter a num", "0") $number = Number($number) If $number = 0 Then ContinueLoop ElseIf $number = 1 Then MsgBox(0, "", "You entered 1") ElseIf $number = 2 Then MsgBox(0, "", "You entered 2") ContinueLoop Else MsgBox(0, "", "You entered " & $number) EndIf ExitLoop WEnd [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
tutor2000 Posted July 5, 2004 Share Posted July 5, 2004 I have a 300 or so line script with a tangle of If/Else statements. I would like some of the Else's to instruct the script to start over again, how can I do this in the most simple way? Thanks in advance.Look at case in the help fileIt really helped me out a lot when I started using itRick Link to comment Share on other sites More sharing options...
BrokenDynasty Posted July 5, 2004 Author Share Posted July 5, 2004 Does ContinueLoop exit the If statement the script is in and continue within the While Statement, to the next conditional? Link to comment Share on other sites More sharing options...
pekster Posted July 5, 2004 Share Posted July 5, 2004 Does ContinueLoop exit the If statement the script is in and continue within the While Statement, to the next conditional?As soon as the ContinueLoop command is hit, it will cycle to the top of the loop. It will also iterate the count when dealing with a For loop. Note that when using a While loop this will test the condition before execution of the next loop cycle, but it will not for a Do-Until loop because the conditional testing comes at the end, not the top. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
Nutster Posted July 6, 2004 Share Posted July 6, 2004 I thought ContinueLoop actually goes to the bottom of the loop, which triggers incrementing for For or testing for Until. It then goes to the top of the loop and tests for For and While before going back into the loop. Let me see. $x = 1 $msg = "" Do $msg = $msg & ", " & $x $x = $x + 1 If $x > 5 And $x < 15 Then ContinueLoop Until $x > 10 $msg = StringTrimLeft($msg, 2) MsgBox(0, "Testing", $msg)If ContinueLoop does not trigger the test, then the result in $msg should go beyond 10. The result I get is:1, 2, 3, 4, 5, 6, 7, 8, 9, 10Therefore Do-Until is tested on ContinueLoop. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... 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