Jump to content

How do I do this without a GoTo Command?


Recommended Posts

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?

Link to comment
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!

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...