IanN1990 Posted September 7, 2016 Posted September 7, 2016 (edited) Hi, I am writing a function which exits the script at 12pm. I thought instead of pooling or checking the time every x seconds, I could do this? #NoTrayIcon AdlibRegister("ExitScript", (86400-@Sec-((@hour*60)+@min)*60)*1000) While 1 sleep(100) WEnd Func ExitScript() Exit EndFunc Is there any dangers of using a 86400000 AdlibRegister? I cant find anything in the help file which states a max value. Edited September 11, 2016 by IanN1990
ViciousXUSMC Posted September 7, 2016 Posted September 7, 2016 Should be fine, I have used large values before without issue. Though I think best practice has AdlibRegister used for fast repeated passes for a certain event more so than a long term timer, thats not to say it wont work or is a bad idea.
Moderators JLogan3o13 Posted September 7, 2016 Moderators Posted September 7, 2016 The help file states: The adlib function should be kept simple as it is executed often and during this time the main script is paused. Also, the time parameter should be used carefully to avoid CPU load. I would personally go with polling the system time, but it is just that - personal preference. The questions you should ask yourself are: Are there any other actions in the script that are failing because of the pausing during the AdlibRegister check? and Is using it in this manner creating a noticeable CPU increase as opposed to other methods? If the answer to both is no, then it sounds like you've answered your own question. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Malkey Posted September 7, 2016 Posted September 7, 2016 Two things you should know:- My english speaking culture has the convention of 12pm standing for 12:00 midday; and, The "Time" parameter in the AdlibRegister function is in milliseconds, not seconds. So in your script (in post#1), if the script was started at 22:30:25, the adlib function, "ExitScript", would be called every 5.375secs, where 5375ms = 86400 - 25 - ((22 * 60) + 30) * 60 = 86400 - @Sec - ((@hour * 60) +@min) * 60 = (equals) the actual time value parameter when the adlib function is registered.
IanN1990 Posted September 10, 2016 Author Posted September 10, 2016 (edited) Well spotted, i had not implemented the code yet so i didn't notice this problem! I have updated original code so it benefits others Edited September 10, 2016 by IanN1990
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