Use of idle events in Pb and usage of idle (n) functions:

Source: Internet
Author: User

This function resets the timer after each activity (for example, pressing the keyboard or moving the mouse), and triggers the Idle event of the Application object after n seconds.
Syntax Idle (n)
Parameter n: Specifies the idle time interval, in seconds. When the value of this parameter is set to 0, the Idle detection is stopped, and the return value of the Idle event of the Application object is no longer Integer. 1 is returned when the function is successfully executed, and the timer is started. If the timer cannot be started or the value of n is set to 0, the function returns-1. If the value of any parameter is NULL, the Idle () function returns NULL. Using the Idle () function, applications can construct their own screen saver to avoid leakage of secure data. If the Idle () function is called again with a non-zero parameter after the timer has been started using the Idle () function, the function resets the time interval, but does not start a new timer. After the Idle () function starts the timer, if no application is operated at the specified interval (from the last operation of the user), the Idle event of the Application object is triggered, in this event, you can write a series of Code such as closing the window and logging out of the database, and then Restart the application using the Restart () function to keep the application confidential. The system automatically resets the timer (that is, re-starts the timer) in any of the following circumstances: n
The user moves the mouse or clicks the mouse in any window of the application (when double-clicking the mouse, the click event is triggered first) n when a window of the application is the current window, the user presses any one or more keys. n when the window of the application is minimized, when you click or move the mouse on the application icon n to minimize the number of windows in the application and the application is the current application (the application name is highlighted, editing control caused by pressing any key n in the visual data window to retrieve data (it refers to the editing control floating in the current row/column of the data window)
  
Idle event:
Description
Occurs when the Idle function has been called in an application object script and the specified number of seconds have elapsed with no mouse or keyboard activity.
Event ID
Event ID Objects
None Application
Arguments
None
Return value
None (do not use a RETURN statement)
  
For examples:
This statement in an application script causes the Idle event to be triggered after 300 seconds of inactivity:
Idle (1, 300)
In the Idle event itself, this statement closes the application:
HALT CLOSE
  
Idle PowerScript function:
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.
Return value
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
Application or callthe Restart function.
The timer is reset when any of the following activities occur:
  
<1> A mouse movement or mouse click in any window of the application
<2> Any keyboard activity when a window of the PowerBuilder application is current
<3> A mouse click or any mouse movement over the icon when a PowerBuilder application is minimized
<4> Any keyboard activity when the PowerBuilder application is minimized and is current (its name is highlighted)
<5> Any retrieval on a visible DataWindow that causes the edit control to be painted
  
Tip to capture movement, write script in the mousemove or key events of the window or sheet. (keyboard activity does not trigger mousemove events .) disable the datawindow control and Tab ordering during iterative retrieves so the idle timer is not reset.
His statement sends an idle event after five minutes of inactivity:
  
Idle (1, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.