Sets a timer so that PowerBuilder triggers an Application Idle event when there has been no user activity for a specified number of seconds.
Idle ( n )
Argument |
Description |
---|---|
n |
The number of seconds of user inactivity allowed before PowerBuilder triggers an Application Idle event. A value of 0 terminates Idle detection. |
Integer. Returns 1 if it starts the timer, and -1 if it cannot start the timer or n is 0 and the timer has not been started. Note that when the timer has been started and you change n, Idle does not start a new timer; it resets the current timer interval to the new number of seconds. If n is null, Idle returns null. The return value is usually not used.
Use Idle to shut off or restart an application when there is no user activity. This is often done for security reasons.
Idle starts a timer after each user activity (such as a keystroke or a mouse click), and after n seconds of inactivity it triggers an Idle event. The Idle event script for an application typically closes some windows, logs off the database, and exits the application or calls the Restart function.
The timer is reset when any of the following activities occur:
A mouse movement or mouse click in any window of the application
Any keyboard activity when a window of the PowerBuilder application is current
A mouse click or any mouse movement over the icon when a PowerBuilder application is minimized
Any keyboard activity when the PowerBuilder application is minimized and is current (its name is highlighted)
Any retrieval on a visible DataWindow that causes the edit control to be painted
This statement sends an Idle event after five minutes of inactivity:
Idle(300)
This statement turns off idle detection:
Idle(0)
This example shows how to use the Idle event to stop the application and restart it after two minutes of inactivity. This is often used for computers that provide information in a public place.
Include this statement in the script for the application’s Open event:
Idle(120) // Sends an Idle event after 2 minutes.
Include these statements in the script for the application’s Idle event to terminate the application and then restart it:
// Statements to set the database to the desired
// state
...
Restart() // Restarts the application