Timers

A Timer is a function that is scheduled to run at user defined times. Any function may be turned into a timer through one of three Timer Registration Functions described in the next section. When a function has been turned into a timer function, we generally say the function "has been registered as a timer" or "the function IS a timer". Timers are used to create:

  1. Constantly running functions (run_at_interval) at user defined intervals.

  2. Functions that run only one time after some delay period. (run_after_time)

  3. Functions that run periodically at user-defined intervals after an initial delay period (run_timer).

Examples


Timer Functions

 run_at_interval( func_name,  interval)

^ Runs [func_name] every [interval] seconds, beginning [interval] sections from the call.

 run_after_time( func_name,  delay)

^ Runs [func_name] one time only after [delay] seconds.

 run_timer( func_name,  delay,  interval)

^ Executes [func_name] function, beginning [delay] seconds after being called, and then executed every [interval] seconds after that.

 stop_timer( func_name )

^ Stops/Cancels [func_name] timer functionality. Re-schedule with one of the above timer functions.

 is_timer_scheduled( func_name )

^ This returns true if [func_name] is scheduled to run at any time in the future. False for all other conditions.

get_timer_remaining( func_name )

^ Returns the seconds remaining until [func_name] will be called next. Returns 0 if the timer is stopped.