Sign in to follow this  
Followers 0
BrokenDynasty

Command to restart script?

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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 file

It really helped me out a lot when I started using it

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

Does ContinueLoop exit the If statement the script is in and continue within the While Statement, to the next conditional?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. :ph34r:

$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, 10

Therefore Do-Until is tested on ContinueLoop.


David Nuttall
Nuttall 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...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0