Hello.
So, i've built a website checking tool, and it works nicelly.. Thing is, it just dies after some hours.
That just doesn't work as you might imagine, if the objective is to keep an eye on things.
And by "dies" i mean i've seen it go down, it just disapears while it is working and closes itself.
Can someone please take a look and see what might be causing this?
I've been banging my head for days now..
(removed)
script "dies" after several hours runing
script "dies" after several hours runing
Last edited by Portwolf on 26 Nov 2018, 18:28, edited 1 time in total.
Re: script "dies" after several hours runing
well, i doubt any one can debug this, other than u urself, obviously, but after taking a cursory look at it, i reckon it might have something to with the liberal usage of Gosubs triggering a user callback exception(0xc000041d)
let it run and check the event logs once it crashes: event viewer -> windows logs -> application and check the exception code its giving u
example, if u never return:
let it run and check the event logs once it crashes: event viewer -> windows logs -> application and check the exception code its giving u
example, if u never return:
Code: Select all
MyFunc() {
static i := 0, init := MyFunc()
MyLabel:
ToolTip % "Blow me up..." ++i
Gosub MyLabel
return
}
Re: script "dies" after several hours runing
It's not GoSubs, it's init := MyFunc() , though swagfag is right,you can only ever call the function itself so many times,before a stackoverflow... Do this instead, init := !init ? MyFunc() : "".
Example of a stackoverflow:
Example of a stackoverflow:
Code: Select all
x()
x(){
Static
i := i ? (i+1) : 1
ToolTip % i
x()
}
live ? long & prosper : regards
Re: script "dies" after several hours runing
theres nothing wrong with static init := MyFunc(). it calls itself once at script startup, avoiding the need to call it explicitly. it doesnt do so recursively, if thats what ure thinking
Re: script "dies" after several hours runing
Taking a quick look, I noticed that a number of your subroutines/labels don't have a "return" after them. This can cause unexpected results, because AutoHotkey will keep going down to the next label, after the next, and processing commands until it hits a "return", unless you have it in a loop or waiting for input or a result.Portwolf wrote: ↑26 Nov 2018, 06:42Hello.
So, i've built a website checking tool, and it works nicelly.. Thing is, it just dies after some hours.
That just doesn't work as you might imagine, if the objective is to keep an eye on things.
And by "dies" i mean i've seen it go down, it just disapears while it is working and closes itself.
Can someone please take a look and see what might be causing this?
I've been banging my head for days now..
https://autohotkey.com/docs/commands/Return.htm
In this pseudo code example, such a script design can have all kinds of problems. You are telling AutoHotkey to jump to a label 3, but it will keep executing until it hits the "return" at label 4. To make it worse, your gosubs or goto can have the code jumping all over, but the program will execute other unwanted labels or subroutines because there is no "return" or code logic to stop it.
Code: Select all
code
Label 1:
code
gosub, Label 3
Label 2:
code
Label 3:
code
Label 4:
code
return
When Label 1 one jumps to Label 3, after Label 3 is done, it will then "jump back" and return to Label 1 or from the point where it started the jump from. Unless of course, you specifically want the program to blend labels together by letting it execute downwards to the next label or group of labels. Making sure subroutines are separate from each other, is what makes gosub much safer to use. And it stops unexpected results.
Code: Select all
code
Label 1:
code
gosub, Label 3
return
Label 2:
code
return
Label 3:
code
return
Label 4:
code
return
GuiClose:
ExitApp
Last edited by SOTE on 29 Nov 2018, 12:51, edited 3 times in total.
Re: script "dies" after several hours runing
another approach to help u narrow it down(though it could be a bit labor intensive, but shouldnt necessarily be all that bad with a bit of text editor kung fu) would be to log every line the script is running and check what the last line was, when it crashed
Re: script "dies" after several hours runing
Thank you all for your help.
Seems like there is some code optimization i need to get into....
Best regards!
Seems like there is some code optimization i need to get into....
Best regards!
Re: script "dies" after several hours runing
I stand corrected, apparently Gosubs have much like functions a limit of sorts(1673 'recursive' calls WITHIN FUNCTIONS),go figure. Using a simple GoTo solves the issue though.
live ? long & prosper : regards
Who is online
Users browsing this forum: Google [Bot] and 54 guests