Creating a new timer

CreateTimer()

Create a new timer


SYNTAX

CreateTimer(event_function, millisecond_interval[, option_flags])

Create a new timer. Timers are useful in any circumstance where the programmer requires an action to be repeated at regular intervals. Multiple timers can be created, and can run concurrently.

event_function

The name of the event function to be called every time the specified interval elapses. The timer is subsequently identified by its event_function. If multiple timers are created, each must have a different event function.

Timer events are subject to CPU time being available for the process. Events can be delayed or missed if the system is busy. A timer event function can return CLOSE_DIALOG or CANCEL_DIALOG if required. See event function return values.

millisecond_interval

The interval in milliseconds between calls to the timer’s event function. The interval specified here is the default, and can be overridden by the StartTimer() function. The interval should be a positive integer.

Under UNIX, the millisecond_interval is rounded up to the next second, because most UNIX system clocks run with granularity of one second.

Under Windows, the millisecond_interval is used.

option_flags

Currently the only flag implemented is TIMER_START. If this argument is omitted, or is 0, the timer is created but does not start running until the StartTimer() function is called.

The function returns 0 if successful, or a negative value if it fails.


EXAMPLE

CreateTimer(evTimer, 1000, TIMER_START}

RELATED TOPICS

DestroyTimer()

StartTimer()

StopTimer()