Progress
Language Reference


WAIT-FOR Statement

Interfaces
OS
SpeedScript
All
All
Yes

The WAIT-FOR statement instructs Progress to stop executing the current block until a specific Progress event occurs. Progress continues to respond to all other incoming events and execute any associated triggers or event procedures while in this wait state.

SYNTAX

WAIT-FOR event-list OF widget-list 
  [ OR event-list OF widget-list ] ...
  [ FOCUS widget ]
  [ PAUSE n ] 

WAIT-FOR "WEB-NOTIFY"
OF DEFAULT-WINDOW
  [ PAUSE n ]
  [ EXCLUSIVE-WEB-USER ] 

event-list

A space or comma-separated list of user-interface events and other Progress events to wait for.

An event can be any event described in the “Events Reference” chapter of this manual.

widget-list

A space- or comma-separated list of widgets with which the event is associated. For more information on referencing widgets, see the Widget Phrase reference entry.

FOCUS widget

Specifies the widget that initially receives input focus when the WAIT-FOR statement is executed. The value widget must be a valid reference to a widget (a widget name or handle) that is currently displayed and enabled.

PAUSE n

Specifies a time-out interval for the WAIT-FOR statement. The value n can be any numeric expression. If a period of n seconds elapses between events, the WAIT-FOR automatically terminates.

EXAMPLES

This procedure defines two buttons, defines triggers for them, and enables them. The procedure then waits for the user to close the current window. The initial focus is placed on the button labeled MORE. The user can then choose buttons continuously until closing the window or exiting with the END-ERROR key.

r-wait.p
DEFINE BUTTON more-button LABEL "MORE".
DEFINE BUTTON next-button LABEL "NEXT".

FORM customer.cust-num customer.name more-button next-button
    WITH FRAME brief.

FORM customer EXCEPT cust-num name
    WITH FRAME full.

ON CHOOSE OF more-button
   DISPLAY customer EXCEPT cust-num name WITH FRAME full.

ON CHOOSE OF next-button
   DO:
      HIDE FRAME full.
      FIND NEXT customer NO-ERROR.
      IF AVAILABLE customer
      THEN DISPLAY customer.cust-num customer.name WITH FRAME brief.
   END.

FIND FIRST customer.
DISPLAY customer.cust-num customer.name WITH FRAME brief.

ENABLE more-button next-button WITH FRAME brief.

WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW FOCUS more-button. 

If the user closes the current window then execution continues after the WAIT-FOR statement. In this case, the procedure ends because there are no more statements.

Procedure r-waitpn.p uses the PAUSE option of the WAIT-FOR statement so that you automatically jump ahead to the next record if the user does not perform any action within three seconds after the customer information is displayed.

r-waitpn.p
DEFINE BUTTON more-button LABEL "MORE".
DEFINE BUTTON next-button LABEL "NEXT".
DEFINE VARIABLE jump-ahead AS LOGICAL INITIAL TRUE.

FORM customer.cust-num customer.name more-button next-button
    WITH FRAME brief.FORM customer EXCEPT cust-num name
    WITH FRAME full.

ON CHOOSE OF more-button
   DO:
      DISPLAY customer EXCEPT cust-num name WITH FRAME full.
      jump-ahead = FALSE.
   END.

ON CHOOSE OF next-button
   DO:
     jump-ahead = TRUE.
   END.

ON WINDOW-CLOSE OF CURRENT-WINDOW
   DO:
     QUIT.
   END.

ENABLE more-button next-button WITH FRAME brief.

DO WHILE TRUE:
   IF jump-ahead
   THEN RUN next-cust.

   WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW OR CHOOSE OF next-button
           FOCUS more-button PAUSE 3.
END.

PROCEDURE next-cust:
   HIDE FRAME full.
   FIND NEXT customer NO-ERROR.
   IF AVAILABLE customer
   THEN DISPLAY customer.cust-num customer.name WITH FRAME brief.
END. 

In this example, the code for find the next customer has been moved to an internal procedure. The WAIT-FOR statement has been placed inside a DO loop. The loop iterates when the user chooses the NEXT button or three seconds elapse. (If the user closes the window, the QUIT statement is executed and the loop does not iterate.) On each iteration, if the variable jump-ahead is TRUE, then the next-cust procedure is run to find and display the next customer. If the user chooses the MORE button for a customer, jump-ahead is set to FALSE. This prevents the procedure from automatically jumping ahead to the next customer. Instead, the user can spend time examining the data. To move ahead to the next customer, the user must explicitly choose the NEXT button. At that point, jump-ahead is reset to TRUE.

NOTES

SEE ALSO

DISABLE Statement, ENABLE Statement, ON Statement, Trigger Phrase, Widget Phrase


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095