Sign in to follow this  
Followers 0
multiloser

Only one non-working part....

4 posts in this topic

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()

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

Nevermind, I see what I did wrong.

When I put Global $Amount = 1000 before Func Zeroth(), I forgot to put it before it was sent to Zeroth()

Works perfect! Thanks!

Share this post


Link to post
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

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