WAIT-FOR statement (ABL only)
This WAIT-FOR statement instructs the AVM to stop executing the current block until a specific ABL event occurs. The AVM continues to respond to all other incoming events and execute any associated triggers or event procedures while in this wait state.
Note: ABL supports a separate version of the WAIT-FOR statement (.NET WAIT-FOR) that blocks for .NET, as well as ABL, events. For more information, see the WAIT-FOR statement (.NET and ABL) reference entry.Syntax
event-list
A space or comma-separated list of user-interface events and other ABL events to wait for.An event can be any event described in the "Handle-based Object Events Reference" section.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.FOCUSwidget
PAUSEn
ExamplesThis 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.
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.
The following procedure 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:
In this example, the code for finding 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
- Any widget associated with an event must be enabled before you wait on it.
- In general, do not use an UPDATE statement in an application that executes a WAIT-FOR statement. One exception is updating fields in a dialog box.
- In general, if you nest two WAIT-FOR statements in a single ABL application (where the nested WAIT-FOR executes in a trigger), you must ensure that your application satisfies the nested WAIT-FOR first. The event that satisfies the outer WAIT-FOR statement should be the terminating event for your application.
- In general, when a modal dialog box is active, the
event-list
can reference only events supported by the active dialog box and the widgets it contains. There are two exceptions:- In batch mode (running with the
-b
startup parameter), the WAIT-FOR statement supports only the following events:- The PROCEDURE-COMPLETE event occurs for an asynchronous request handle when the current ABL session receives the response message from the AppServer that executed the request. When the WAIT-FOR statement executes, it processes any PROCEDURE-COMPLETE event that has occurred but has not yet been processed.
- PROCEDURE-COMPLETE events from a single AppServer connection are processed in the order that the associated asynchronous requests were originally generated. To ensure that all pending PROCEDURE-COMPLETE events are handled by a single WAIT-FOR statement, specify a single PROCEDURE-COMPLETE event for the last asynchronous request handle generated before the WAIT-FOR statement.
- To process a PROCEDURE-COMPLETE event for a particular asynchronous request handle, the AVM:
- Decrements the ASYNC-REQUEST-COUNT attribute for the server referenced by SERVER attribute for the asynchronous request handle.
- Decrements the ASYNC-REQUEST-COUNT attribute for a persistent procedure, if the PERSISTENT-PROCEDURE attribute of the asynchronous request handle refers to a valid persistent procedure.
- Sets the COMPLETE attribute for the asynchronous request handle to TRUE.
- Sets the STOP, QUIT, and ERROR attributes for the asynchronous request handle appropriately as indicated by the response message from the AppServer.
- Sets the return value for the RETURN-VALUE function, if a return value was returned by the AppServer.
- Stores any error information returned from the AppServer in the ERROR-STATUS system handle.
- Attempts to execute the event procedure specified by the EVENT-PROCEDURE and the EVENT-PROCEDURE-CONTEXT attributes for the asynchronous request handle, if EVENT-PROCEDURE is not the empty string (“”).
- Sets each INPUT parameter for the event procedure to the Unknown value (
?
) or, if the parameter is a TEMP-TABLE, the TEMP-TABLE remains unchanged, if the response message indicates that the remote request finished with a STOP, ERROR, or QUIT condition.- Sets the INPUT parameter values for the event procedure to the OUTPUT and INPUT-OUTPUT parameter values returned by the remote procedure, if the response message indicates that the remote request completed successfully.
- Displays an error message, if a specified event procedure fails to execute for any reason.
- Raises any unhandled STOP condition, ERROR condition, or QUIT condition in the context of the WAIT-FOR statement, if the event procedure completes execution with that condition.
- These are possible causes for failing to execute the event procedure for a PROCEDURE-COMPLETE event. All of these failures raise a STOP condition in the context of the WAIT-FOR statement:
- The procedure handle referenced by the EVENT-PROCEDURE-CONTEXT attribute is no longer valid.
- The internal procedure specified by the EVENT-PROCEDURE attribute cannot be found.
- The parameters to the internal procedure specified by the EVENT-PROCEDURE attribute are not all INPUT parameters.
- The parameter signature of the internal procedure specified by the EVENT-PROCEDURE attribute does not match the output parameters returned in the response message for the asynchronous request.
- For SpeedScript, the WAIT-FOR statement instructs WebSpeed to stop executing the current block until the WEB-NOTIFY event occurs. The WEB-NOTIFY event is intended for internal use only, it does not apply to SpeedScript programming.
See alsoDISABLE statement, ENABLE statement, ON statement, Trigger phrase, WAIT-FOR statement (.NET and ABL), Widget phrase
OpenEdge Release 10.2B
|