tryout1 Posted July 7, 2006 Share Posted July 7, 2006 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 Link to comment Share on other sites More sharing options...
marfdaman Posted July 7, 2006 Share Posted July 7, 2006 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 More sharing options...
bhoar Posted July 7, 2006 Share Posted July 7, 2006 Post the code or preferably a simplified sample that triggers the problem? Perhaps there's a recursion issue. -brendan Link to comment Share on other sites More sharing options...
Nomad Posted July 7, 2006 Share Posted July 7, 2006 my prog works fine but after 1 hour it tel me autoit was closed because Sleep(100*60*$refresh)stack overflowany idea ?thanksa newbieIt 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 Link to comment Share on other sites More sharing options...
marfdaman Posted July 7, 2006 Share Posted July 7, 2006 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 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 More sharing options...
Nomad Posted July 7, 2006 Share Posted July 7, 2006 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 Link to comment Share on other sites More sharing options...
tryout1 Posted July 7, 2006 Author Share Posted July 7, 2006 $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 More sharing options...
Developers Jos Posted July 7, 2006 Developers Share Posted July 7, 2006 the Searchange() is calling itself without finishing ..... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nomad Posted July 7, 2006 Share Posted July 7, 2006 $refresh=2 ;other messageFunc 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 Thensong()ElseSleep(100*60*$refresh)Searchange()EndIfWhat 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. Link to comment Share on other sites More sharing options...
tryout1 Posted July 7, 2006 Author Share Posted July 7, 2006 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 More sharing options...
tryout1 Posted July 7, 2006 Author Share Posted July 7, 2006 TX TX for the explications !! Link to comment Share on other sites More sharing options...
Nomad Posted July 7, 2006 Share Posted July 7, 2006 (edited) TX TX for the explications !! 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 Edited July 7, 2006 by Nomad Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now