Sign in to follow this  
Followers 0
aommaster

How do I do this without a GoTo Command?

7 posts in this topic

Hey guys!

I have a program that runs in a loop. The loop, in ints skeleton form looks like this:

While (certain conditions are not satisfied)

---Submit form

---Append information

---Change information that is comaparable to information in a text file

---Open Text file

---Compare and try to make a match

---If Match is found

------Messagebox "found"

---Else

------Stuff supposed to be here

---Endif

Wend

The problem arises with the like "Stuff supposed to be here". I know for a fact that there will ALWAYS be a match, regardless of the situation. So, it means that the data has been appended incorrectly.

What I want it to do is to then examine the page of information that it is at. There are two possible cases:

1.A form has to be submitted first

2.The data is on the page.

Based on that, I want it to execute the respective part of the script. So, if it finds that the the form is to be submitted, the WHOLE while loop starts over again. Otherwise, it just goes to the line where it appends information, and continues from there.

Any ideas on how to get this done?

Share this post


Link to post
Share on other sites



Use functions.

Share this post


Link to post
Share on other sites

Check out ContinueLoop

Share this post


Link to post
Share on other sites

Use functions.

*slaps forehead* I can't believe I didn't think of it.

Check out ContinueLoop

I took a look at the conitnueloop function, but the problem with that is that there is only one while loop involved, and that contains the whole mess of functions I have.

I think I'll go with JustinReno's advice and just call a function everytime.

Thanks guys!

Share this post


Link to post
Share on other sites

Haha! Turns out I used both, functions, and continueloop to get the program working.

Thanks again guys!

Share this post


Link to post
Share on other sites

I never played with GoTo before today... Got to tell you, it's the messiest thing I ever saw. So easy to get lost in the code.

Proper condition statements, function calls, or proper loop setup and you have some well maintained code that is easier to follow.

Just for kicks, I was playing with confusing code in autoit.. but unfortunately I could still follow the logic unlike GoTo :

GoTo(2, 1)
GoTo(1, 2)

Func GoTo($iVal, $nCase)
    Switch $iVal
        Case 1
            Return _GoToSub1($nCase)
        Case 2
            _GoToSub2($nCase)
    EndSwitch
EndFunc

Func _GoToSub1($nParam)
    Switch $nParam
        Case 1
            MsgBox(16, "Error", "You shouldn't have gotten me... GoodBye")
            Exit
        Case 2
            Return MsgBox(64, "Sub1", "You're exectuing sub 1 function case 2.")
    EndSwitch
    Return
EndFunc

Func _GoToSub2($nParam)
    Switch $nParam
        Case 1
            Return MsgBox(64, "Sub2", "You're executing sub 2 function case 1.")
        Case 2
            MsgBox(16, "Error", "You shouldn't have gotten me... GoodBye")
            Exit
    EndSwitch
    Return
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

True.. I'm not fond of goto commands at all. I'd prefer to use While and For loops.

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