jokke Posted October 5, 2006 Share Posted October 5, 2006 (edited) Hi, I have 2 scripts, one witch i need to trigger every 120 sec, and one to trigger every 60 secounds. For now i have currently used a looping "While" as my counter witch works great for 1 script at the time, but when i try to mix both my scripts together, all the timings get wrong after a few minutes. You can see how my code almost looks like under: expandcollapse popup;Settings $script1_wait =0 $script1_wait2 = 60 $script2_wait =0 $script2_wait2 = 120 $test = 1 $test = 2 ;Functions Func _script1() If $test = 1 Then "My script goes here." $script1_wait = 0 While $script1_wait2 > $script1_wait $script1_wait = $script1_wait +1 Sleep(1000) WEnd EndIf EndFunc Func _script2() If $test2 = 1 Then "My 2nd script goes here" $script2_wait = 0 While $script2_wait2 > $script2_wait $script2_wait = $script2_wait +1 Sleep(1000) WEnd EndIf EndFunc ;Script While 1 = 1 _script1() _script2() WEnd Anyone have any good idea on how i can make counters on both the scripts so main script can wend over and over until one of the scripts are runnable. All help appreciated Edit: I wrote this code on free hand but wrote EndFunc wrong on the sithe. My actual code is EndFunc. Edited October 5, 2006 by jokke UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted October 5, 2006 Share Posted October 5, 2006 (edited) maybe cuz your using Funcend instead of Endfunc when i get home ill come rewrite this for you so it looks alot cleaner, could you please provide a more concrete example with your program cuz its kinda hard to write a script that just sits in a loop adding 1 to a variable then just exits the function and if anything i would recomend looking at a For Loop in the help file Edited October 5, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
lcgreenwald Posted October 5, 2006 Share Posted October 5, 2006 (edited) Try this. expandcollapse popup;Settings $script1_wait = 0 $script1_wait2 = 60 $script2_wait = 0 $script2_wait2 = 120 $test = 1 $test2 = 1 ;Functions Func _script1() If $test = 1 Then ;"My script goes here." EndIf EndFunc ;==>_script1 Func _script2() If $test2 = 1 Then ; "My 2nd script goes here" EndIf EndFunc ;==>_script2 ;Script While 1 $script1_wait = $script1_wait + 1 $script2_wait = $script2_wait + 1 Sleep(1000) If $script1_wait = $script1_wait2 Then $script1_wait = 0 _script1() EndIf If $script2_wait = $script2_wait2 Then $script2_wait = 0 _script2() EndIf WEnd Edited October 5, 2006 by lcgreenwald Link to comment Share on other sites More sharing options...
Xenobiologist Posted October 5, 2006 Share Posted October 5, 2006 Hi, or have a look at TimerInit and TimerDiff. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jvanegmond Posted October 5, 2006 Share Posted October 5, 2006 While 1 func1() sleep(60000) func1() func2() sleep(60000) WEnd Func func1() EndFunc Func func2() EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
jokke Posted October 5, 2006 Author Share Posted October 5, 2006 Thanks alot for all the input on this lcgreenwald's code worked like a charm for me. Thanks alot! UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt. 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