Jump to content

Only one non-working part....


Recommended Posts

Here's the code: (you can skip for now)

Func Zeroth()
Global $oAmount = 1000
Global $oForm = _IEFormGetObjByName ($oMain, "makebet")
Global $oBet = _IEFormElementGetObjByName ($oForm, "howmuch")
First()
EndFunc

Func First()
    _IEFormElementSetValue ($oBet, $oAmount)
    _IEFormSubmit ($oForm)
    _IELoadWait ($oMain)
    _IELinkClickByText ($oMain, "Look at your Archive")
    Second()
EndFunc

Func Second()
    $sString = _IEBodyReadHTML ($oMain)
    StringReplace($sString, 'NOT YOU', '')
    $NotAfter = @extended
    StringReplace($sString, '+', '')
    $YouAfter = @extended
    If $NotAfter > $NotBefore Then
        $oAmount = $oAmount + $oAmount
        $NotBefore = $NotAfter
        _IELinkClickByText ($oMain, "Go back")
        Zeroth()
    ElseIf $YouAfter > $YouBefore Then
        $oAmount = 1000
        $YouBefore = $YouAfter
        _IELinkClickByText ($oMain, "Go back")
        Zeroth()
    EndIf
EndFunc

Basically what this code does is it submits a bet, goes to the archive page, checks if it won or lost.

After it wins/loses:

If it wins, it goes back and bets 1000. This part works.

If it loses, it doubles whatever the amount was. THIS DOES NOT WORK

There is no error, but no matter if it wins or loses, it bets only 1000.

Any ideas?

If I remove the "Global $oAmount = 1000" from Func Zeroth() then it results in an undeclared variable in Func First()

Link to comment
Share on other sites

  • Moderators

1. Declare your global variables outside any function.

2. Are you positive it's getting here?:

If $NotAfter > $NotBefore Then
        $oAmount = $oAmount + $oAmount

P.S.

Everytime you call the function Zeroth(), you reset $oAmount back to 1000, that looks like the desired effect, but thought I'd let you know.

Edited by SmOke_N

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

While it may work, I suggest altering your code to use proper loops. At the moment, you are looping your script by manipulating function calls, which prevents any of your functions from ever returning. You may not experience any problems until you've run it for hours, or even days. But even if you never run the script for long enough to have a problem, it is bad coding to do it that way.

Basically, doing something like this:

Func one()
two()
endfunc

func two()
three()
endfunc

func three()
one()
endfunc

should be avoided. Instead, re-write your code to use a do-until or while-wend loop

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