AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reload - make sure it was successful?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
V@no



Joined: 13 Sep 2007
Posts: 37

PostPosted: Sun Mar 23, 2008 11:01 pm    Post subject: Reload - make sure it was successful? Reply with quote

Hello!
I've been using this little snippet that automatically restarts the script if it was modified, which saves lots of clicking when you test something
Code:
FileGetTime, ScriptModified, %A_ScriptFullPath%, M
SetTimer, CheckReload, 100
Goto SkipCheckReload
CheckReload:
   FileGetTime, ScriptModifiedC, %A_ScriptFullPath%, M
   If (ScriptModifiedC <> ScriptModified)
   {
      Reload
      ExitApp
   }
Return
SkipCheckReload:
;rest of the script

This works great with persistent scripts except for one thing: if you make a critical mistake in the code, the script will quit.
Now, here's the question: how do I detect if script was reloaded without errors?

Thank you.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2737
Location: Australia, Qld

PostPosted: Mon Mar 24, 2008 5:59 am    Post subject: Reply with quote

Code:
Reload
Sleep, 1000
; If the reload succeeded, the script would have already terminated.
MsgBox RELOAD FAILED
It may be possible for this to fail if the computer is under heavy load, though. (i.e. It takes longer than one second to reload the script, but it eventually succeeds.)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group