Jump to content

stack overflow with Sleep


Recommended Posts

Please post the rest of your script. I can't tell what part is causing this (well, actually I can, it's most likely $refresh), but we can't tell why you're doing something wrong.

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

my prog works fine

but after 1 hour it tel me

autoit was closed because

Sleep(100*60*$refresh)

stack overflow

any idea ?

thanks

a newbie

It probably doesn't have anything to do with the Sleep command in general, that just happened to be the spot in the script it was at when the stack got too full. Are you calling functions from within functions without ever letting a function fully complete and return? This is the most common cause for a stack overflow.

Nomad :D

Link to comment
Share on other sites

It probably doesn't have anything to do with the Sleep command in general, that just happened to be the spot in the script it was at when the stack got too full. Are you calling functions from within functions without ever letting a function fully complete and return? This is the most common cause for a stack overflow.

Nomad :D

Yes, but it could also be that he multiplies $refresh every time, and that after an hour the number gets too great. The recursion problem would occur much sooner, I believe.

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

Yes, but it could also be that he multiplies $refresh every time, and that after an hour the number gets too great. The recursion problem would occur much sooner, I believe.

yes, that's possible also, maybe. But if the number got too great wouldn't AutoIt just throw a general out of range error instead of a recursion error? A recursion error is when the stack gets too full, which I think is something like 384 recursions for AutoIt. While it's sleeping it's not doing anything to the stack, and when it's done anything pushed onto the stack by the function is popped.

In any case, there's really no way to be 100% sure of anything without some more input from tryout1.

Nomad :D

Link to comment
Share on other sites

$refresh=2 ;other message

Func Searchange()

If FileExists("newmess.html") Then

$actualmess = FileReadLine("newmess.html")

Else

$actualmess = "0"

EndIf

$newmess="0"

InetGet ( "http://www.autoitscript.com/forum/index.php?showtopic=28822", "newmess.html" ,1 )

$newmess = FileReadLine("newmess.html")

If $newmess<>$actualmess Then

song()

Else

Sleep(100*60*$refresh)

Searchange()

EndIf

Link to comment
Share on other sites

$refresh=2 ;other message

Func Searchange()

If FileExists("newmess.html") Then

$actualmess = FileReadLine("newmess.html")

Else

$actualmess = "0"

EndIf

$newmess="0"

InetGet ( "http://www.autoitscript.com/forum/index.php?showtopic=28822", "newmess.html" ,1 )

$newmess = FileReadLine("newmess.html")

If $newmess<>$actualmess Then

song()

Else

Sleep(100*60*$refresh)

Searchange()

EndIf

What does song() do when it completes? does it return or does it call a function? The Searchange() at the end of the function appears to be making this a recursive function since you never fully allow it to complete and return, hence recursing. Which will eventually cause a stack overflow. :D
Link to comment
Share on other sites

AutoItSetOption ( "MouseCoordMode", 0 )

$refresh=2 ;other message

$mess=1

Func Searchange()

If FileExists("newmess.html") Then

$actualmess = FileReadLine("newmess.html")

Else

$actualmess = "0"

EndIf

$newmess="0"

InetGet ( "http://www.autoitscript.com/forum/index.php?showtopic=28822", "newmess.html" ,1 )

$newmess = FileReadLine("newmess.html")

If $newmess<>$actualmess Then

song()

Else

Sleep(100*60*$refresh)

Searchange()

EndIf

EndFunc

Func song()

If $mess=1 Then

SoundSetWaveVolume ( 100 )

SoundPlay ( "newmessage.wav" ,1 )

Searchange()

Else

SoundSetWaveVolume ( 10 )

SoundPlay ( "ok.wav" ,1 )

Sleep(100*60*$refresh)

Searchange()

EndIf

Link to comment
Share on other sites

TX TX for the explications !! :wacko:

No problem... yup, that's recursion if I ever seen it, hehe. You should create a main function which calls these functions based on the value of a variable which is set under the conditions used to determine which function you are calling. Then the functions can finish, return to the main function, read the variable to determine what function to call, and repeat the process. Then you will not be recursing and you will not get that error. That's the method I use for conditions like this, there are other methods as well.

Nomad :D

Edited by Nomad
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...