Causes a Timer event in a window to occur repeatedly at the specified interval. When you call Timer, it starts a timer. When the interval is over, PocketBuilder triggers the Timer event and resets the timer.
Timer ( interval {, windowname } )
Argument |
Description |
---|---|
interval |
The number of seconds that you want between Timer events. interval can be a whole number or fraction greater than 0 and less than or equal to 4,294,967 seconds. If interval is 0, Timer turns off the timer so that it no longer triggers Timer events. |
windowname (optional) |
The window in which you want the timer event to be triggered. The window must be an open window. If you do not specify a window, the Timer event occurs in the current window. |
Integer. Returns 1 if succeeds and -1 if an error occurs. If any argument’s value is null, Timer returns null.
Do not call the Timer function in the Timer event. The timer gets reset automatically and the Timer event retrigger sat the interval that has already been established. Call the Timer function in another event’s script when you want to stop the timer or change the interval.
This statement triggers a Timer event every two seconds in the active window:
Timer(2)
This statement stops the triggering of the Timer event in the active window:
Timer(0)
These statements trigger a Timer event every half second in the window w_Train:
Open(w_Train)
Timer(0.5, w_Train)
This example causes the current time to be displayed in a StaticText control in a window. Calling Timer in the window’s Open event script starts the timer. The script for the Timer event refreshes the displayed time.
In the window’s Open event script, the following code displays the time initially and starts the timer:
st_time.Text = String(Now(), "hh:mm")
Timer(60)
In the window’s Timer event, which is triggered every minute, this code displays the current time in the StaticText st_time:
st_time.Text = String(Now(), "hh:mm")