Jump to content

Recommended Posts

Posted (edited)

Up until now, I've been using While statements to create my program loops,

but I've been having trouble with it on other programs, so I need to move on to Func () statements.

This is part of a script I have going: (you can skip it for now)

BEGIN CODE

$sString = _IEBodyReadHTML ($oMain)

StringReplace($sString, 'NOT YOU', '')

$NotBefore = @extended

StringReplace($sString, '+', '')

$YouBefore = @extended

_IELinkClickByText ($oMain, "Go back to Money Making Game")

$oAmount = 1000

$oForm = _IEFormGetObjByName ($oMain, "makebet")

$oBet = _IEFormElementGetObjByName ($oForm, "howmuch")

First()

Func First()

_IEFormElementSetValue ($oBet, $oAmount)

_IEFormSubmit ($oForm)

_IELinkClickByText ($oMain, "Look at your Bet Archive")

$sString = _IEBodyReadHTML ($oMain)

StringReplace($sString, 'NOT YOU', '')

$NotAfter = @extended

StringReplace($sString, '+', '')

$YouAfter = @extended

Second()

EndFunc

Func Second()

If $NotAfter > $NotBefore Then

$oAmount = $oAmount + $oAmount

$NotBefore = $NotAfter

_IELinkClickByText ($oMain, "Go back to Money Making Game")

First()

ElseIf $YouAfter > $YouBefore Then

$oAmount = 1000

$YouBefore = $YouAfter _IELinkClickByText ($oMain, "Go back to Money Making Game")

First()

Else

Sleep (1000)

_IEAction ($oMain, "Refresh")

Second()

EndIf

EndFuncEND CODE

I get:

"Line 45

If $NotAfter > $NotBefore Then

If ^ ERROR

Error: Variable used without being declared."

This probably isn't a Func() mistake, but I don't know what's wrong or how to fix it!!!

I thought I declared them!

Look at the bolds above.

Why doesnt this work!!!!!

AHHH!

Thanks! (lol)

Edited by multiloser
Posted (edited)

You declared the variable in one function and used it in another. When you create a variable in a function, it is automatically deleted when the function is exited. You must globally declare it in the main part of your program. Hope this helps.

EDIT: you used them in the main part, but you must specifically GLOBALLY declare them before you use them.

Edited by hearurscream

Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Posted

You declared the variable in one function and used it in another. When you create a variable in a function, it is automatically deleted when the function is exited. You must globally declare it in the main part of your program. Hope this helps.

EDIT: you used them in the main part, but you must specifically GLOBALLY declare them before you use them.

And when I modify it in a function will that modification carry over?

Posted

I believe so, try it and see.

Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Posted (edited)

I've bolded my modifications....

Same result...

Am I still missing more? Do I need to Globally declare the variables INSIDE the functions?

Global $NotAfter = 0

Global $YouAfter = 0

$sString = _IEBodyReadHTML ($oMain)

StringReplace($sString, 'NOT YOU', '')

Global $NotBefore = @extended

StringReplace($sString, '+', '')

Global $YouBefore = @extended

_IELinkClickByText ($oMain, "Go back to Money Making Game")

Global $oAmount = 1000

$oForm = _IEFormGetObjByName ($oMain, "makebet")

$oBet = _IEFormElementGetObjByName ($oForm, "howmuch")

First()

Func First()

_IEFormElementSetValue ($oBet, $oAmount)

_IEFormSubmit ($oForm)

_IELinkClickByText ($oMain, "Look at your Bet Archive")

$sString = _IEBodyReadHTML ($oMain)

StringReplace($sString, 'NOT YOU', '')

$NotAfter = @extended

StringReplace($sString, '+', '')

$YouAfter = @extended

Second()

EndFunc

Func Second()

If $NotAfter > $NotBefore Then

$oAmount = $oAmount + $oAmount

$NotBefore = $NotAfter

_IELinkClickByText ($oMain, "Go back to Money Making Game")

First()

ElseIf $YouAfter > $YouBefore Then

$oAmount = 1000

$YouBefore = $YouAfter

_IELinkClickByText ($oMain, "Go back to Money Making Game")

First()

Else

Sleep (1000)

_IEAction ($oMain, "Refresh")

Second()

EndIf

EndFunc

Edited by multiloser
Posted

Nevermind! It works!

But now it just refreshes over and over again

(stuck on refresh part)

Are the "If $NotAfter > $NotBefore Then" type parts valid?

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
  • Recently Browsing   0 members

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