Consultor Eletrônico



Kbase 12354: PROCESS EVENTS and the active WAIT-FOR statement
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
PROCESS EVENTS and the active WAIT-FOR statement


The PROCESS EVENTS statement processes all outstanding events
that have been queued up while in an iterating block.

However, in PROGRESS Version 7.2A, the PROCESS EVENTS statement is
tied to the active WAIT-FOR statement. This means that the widget to
which the WAIT-FOR statement is tied must be visible at the time
PROGRESS executes the PROCESS EVENTS statement.

When you include a PROCESS EVENTS statement in a called procedure
that either does not contain a WAIT-FOR statement or that causes
the widget against which an event is being 'waited for" to be NOT
visible, PROGRESS generates the following error message:

"Wait-for state is not waiting for any events in the current
active dialog-box. (4124)"

Workaround: 1) Trap the error message by surrounding the WAIT-FOR
statement with the following block of code:
DO ON ENDKEY UNDO
RETRY DO ON ENDKEY UNDO
RETRY:
2) Create a WAIT-FOR statement in the called procedure
that is tied to a widget local to the procedure.

See the attached code examples for more details.


This behavior will change in a future release of PROGRESS Version 7
where PROCESS EVENTS will no longer be tied to the active WAIT-FOR
statement.


/* prog1.p */

DEF BUTTON but-1 LABEL "run prog2".
DEF NEW SHARED VAR testwindow AS WIDGET-HANDLE.
DEF VAR tchar AS CHAR VIEW-AS TEXT.

FORM
SKIP(1)
" Press Button for demonstration."
tchar SKIP(1)
but-1 AT 12
SKIP(1)
WITH FRAME frame-a NO-LABELS WIDTH 40.

CREATE WINDOW testwindow
ASSIGN
title = "PROCESS EVENTS test"
message-area = no
resize = no
height-chars = frame frame-a:height-chars
width-chars = frame frame-a:width-chars
status-area = no
row = 5
col = 5.

CURRENT-WINDOW = testwindow.

ON CHOOSE of but-1 DO:
testwindow:window-state = window-minimized.
RUN prog2.p.
testwindow:window-state = window-maximized.
END.

ENABLE ALL WITH FRAME frame-a.

DO ON ENDKEY UNDO, RETRY
ON ERROR UNDO, RETRY:
WAIT-FOR WINDOW-CLOSE of CURRENT-WINDOW.
END.

DELETE WIDGET testwindow.

--------------------------------cut here ----------------------------

/* prog2.p called by prog1.p */

DEF BUTTON but-2 LABEL "Quit".
DEF VAR vleave AS LOGICAL.
DEF VAR vint AS INT.

FORM
"currently processing"
vint
SKIP(.5)
but-2 AT 13
SKIP (.5)
WITH FRAME frame-b VIEW-AS DIALOG-BOX width 30 NO-LABELS.

but-2:sensitive = true.

VIEW FRAME frame-b.

ON CHOOSE OF but-2
DO:
vleave = true.
END.

ON ENTRY OF but-2 DO:
REPEAT vint = 1 to 5000:
DISPLAY vint WITH FRAME frame-b.
PROCESS EVENTS.
IF vleave THEN LEAVE.
END.
END.

WAIT-FOR GO OF FRAME frame-b.

/* Use of the following WAIT-FOR statement will
generate the aforementioned error message.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. */

Progress Software Technical Support Note # 12354