Idle

Description

Sets a timer so that PowerBuilder triggers an Application Idle event when there has been no user activity for a specified number of seconds.

Syntax

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.

Returns

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.

Usage

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:

Examples

Example 1

This statement sends an Idle event after five minutes of inactivity:

Idle(300)

Example 2

This statement turns off idle detection:

Idle(0)

Example 3

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.

Example 4

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

See also