Jump to content

[Solved] General Question about AdlibRegister


IanN1990
 Share

Recommended Posts

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 by IanN1990
Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...