Dag Posted January 2, 2007 Share Posted January 2, 2007 hello maybe someone can give me a tip , function name in help file or a sample i try to explain my problem: in my script i have a loop, and i need to run some other functions every 5min and other every 2h thanks for help and sorry for my english :F Link to comment Share on other sites More sharing options...
tmo Posted January 2, 2007 Share Posted January 2, 2007 (edited) if u somehow know how long the script needs to pass the loop once you can do it like this: lets assume the script needs 1 second to pass the loop $i = 0 While true If Mod($i, 60) = 0 Then ;this part is done every minute EndIf If Mod($i, 60*60*2) = 0 Then ;this part is done every 2 hours EndIf $i += 1 ;....your other code.... WEnd be sure to inform yourself about AdLibEnable(), too. Edited January 2, 2007 by tmo Link to comment Share on other sites More sharing options...
Dag Posted January 2, 2007 Author Share Posted January 2, 2007 (edited) tmo, thx for reply i can't use your method in my script you can choose some parameters, and depand of your choose script need 1s to 10s to pass the loop so if i use your solution , my script call function every min 2h, max 20h if i'm correct anyway, i need some countdown or something like that Edited January 2, 2007 by Dag Link to comment Share on other sites More sharing options...
tmo Posted January 2, 2007 Share Posted January 2, 2007 so you should decide to use AdLibEnable() Link to comment Share on other sites More sharing options...
Dag Posted January 2, 2007 Author Share Posted January 2, 2007 a already test AdlibEnable and it seems work fine thx for help Link to comment Share on other sites More sharing options...
Dag Posted January 2, 2007 Author Share Posted January 2, 2007 (edited) after further tests i found that i can use this function once only last AdlibEnable work, so if i use 4 AdlibEnable to call 4 diferent functions, only last one work here is an example of mu code if $aaa = 1 then AdlibEnable ( "bbb" , 20000) endif if $ccc = 1 then AdlibEnable ( "ddd" , 30000) endif if $eee = 1 then AdlibEnable ( "fff" , 40000) if $ggg = 1 then AdlibEnable ( "hhh" , 10000) EndIf endif While (1) MouseDown ("Right") Call ("refocus") MouseUp ("Right") Send (" ") Sleep ($speed) WEnd Edited January 2, 2007 by Dag Link to comment Share on other sites More sharing options...
tmo Posted January 2, 2007 Share Posted January 2, 2007 now think about my first method once again. what about having global variable $i which increases each time the adlib-function is called. then you can use the Mod($i, x) method again. Link to comment Share on other sites More sharing options...
seandisanti Posted January 2, 2007 Share Posted January 2, 2007 now think about my first method once again. what about having global variable $i which increases each time the adlib-function is called. then you can use the Mod($i, x) method again.or you can just have one adlib function that calls 4 other functions as necessary based on global variables... there are alot of ways to do what you want... I think i would go with TimerStart() and TimerDiff(). you can start a timer for each of the optional durations, and have TimerDiff compared for each at necessarily variable increments, and you won't need to worry about adblibs or seperate functions at all. Link to comment Share on other sites More sharing options...
improbability_paradox Posted January 2, 2007 Share Posted January 2, 2007 or you can just have one adlib function that calls 4 other functions as necessary based on global variables... there are alot of ways to do what you want... I think i would go with TimerStart() and TimerDiff(). you can start a timer for each of the optional durations, and have TimerDiff compared for each at necessarily variable increments, and you won't need to worry about adblibs or seperate functions at all.I was just about to recommend the TimerDiff() function myself! from the helpfile, this example...CODE$begin = TimerInit()sleep(3000)$dif = TimerDiff($begin)MsgBox(0,"Time Difference",$dif) Link to comment Share on other sites More sharing options...
The Kandie Man Posted January 2, 2007 Share Posted January 2, 2007 You didn't post the full script, but this is how you should probably do it: Dim $i_TimeStamp1 = TimerInit() Dim $i_TimeStamp2 = TimerInit() Dim $i_TimeStamp3 = TimerInit() Dim $i_TimeStamp4 = TimerInit() While 1 MouseDown ("Right") Call ("refocus") MouseUp ("Right") Send (" ") Sleep ($speed) IF TimerDiff($i_TimeStamp1)/1000 >= 20000 Then bbb() $i_TimeStamp1 = TimerInit() EndIf IF TimerDiff($i_TimeStamp2)/1000 >= 30000 Then ddd() $i_TimeStamp2 = TimerInit() Endif If TimerDiff($i_TimeStamp3)/1000 >= 40000 Then fff() $i_TimeStamp3 TimerInit() EndIf If TimerDiff($i_TimeStamp4)/1000 >= 10000 Then hhh() $i_TimeStamp4 = TimerInit() EndIf WEnd "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire 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