Consultor Eletrônico



Kbase P50400: Conflicting CHOOSE and WAIT-FOR statements cause focus issue
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   06/11/2003
Status: Unverified

SYMPTOM(s):

The calling procedure can invoke the external procedure in two ways: By pressing the help key 'F2' or choosing a field in a CHOOSE statement list.

Focus is not going to the frame of the called procedure when F2 is used to run the external procedure.

Focus is going to the frame of the called procedure as expected when choosing a field in the CHOOSE statement list is used to run the external procedure.

The external procedure has a WAIT-FOR statement.

This is the calling procedure "tstfrm1.p":

define variable menu1 as char extent 5 format "x(40)" initial
['Option 1','Option 2','Option 3','Option 4','Exit'] no-undo.

form
menu1
with frame f-menu1 title "Menu 1" width 42 no-labels.

on help anywhere do:
run tstfrm2.p.
end.

repeat:
view frame f-menu1.
display menu1 with frame f-menu1.
do on endkey undo,leave:
choose field menu1 with frame f-menu1.
if frame-index = extent(menu1) then leave.
run tstfrm2.p.
end.
end.

This is the external procedure "tstfrm2.p":

define variable menu1 as char extent 5 format "x(10)" initial
['Option 1','Option 2','Option 3','Option 4','Exit'] no-undo.
define variable hlp as char no-undo.

form
menu1
with frame f-menu2 title "Overlay Menu" overlay row 5 width 12 no-labels
centered.

form
hlp view-as editor size 78 by 40
with frame f-help overlay no-labels size 80 by 15 centered row 5
scrollable title "Help Display" view-as dialog-box top-only.

repeat:
view frame f-menu2.
display menu1 with frame f-menu2.
do on endkey undo,leave:
choose field menu1 with frame f-menu2.
if frame-index = extent(menu1) then leave.
run myhelp.
end.
end.

procedure myhelp.
view frame f-help.
assign hlp = "Here is some testing text for the help display".
display hlp
with frame f-help.
wait-for end-error of frame f-help focus hlp.
hide frame f-help no-pause.
end procedure.

CAUSE:

This is an application design error. Since both the CHOOSE and the WAIT-FOR statements are input blocking statements, the CHOOSE statement has what we call an implied WAIT-FOR statement.

Since only ONE input blocking statement or WAIT-FOR statement can be active at any given time, the conflict between the CHOOSE and the WAIT-FOR statements caused the odd behavior described above.

Running the external procedure by pressing 'F2' does not satisfy the CHOOSE statement that is left hanging there waiting for action. This causes a conflict between the CHOOSE and the WAIT-FOR statements to occur and the focus stays on the calling procedure frame.

Running the external procedure by selecting an item of the CHOOSE statement field list satisfies the CHOOSE statement and moves the focus to the new frame of the called procedure because the CHOOSE statement of the calling procedure is not blocking for input anymore.

FIX:

One solution for this specific conflict is to hide the first frame of the active CHOOSE statement calling procedure ·testfrm1.p· before running the second procedure ·tstfrm2.p· which has the WAIT-FOR statement.

The following modified calling procedure demonstrates this solution and resolves this conflict:

define variable menu1 as char extent 5 format "x(40)" initial
['Option 1','Option 2','Option 3','Option 4','Exit'] no-undo.

form
menu1
with frame f-menu1 title "Menu 1" width 44 no-labels.

on help anywhere do:
HIDE FRAME f-menu1. /*** added code ***/
run tstfrm2.p.
VIEW FRAME f-menu1. /*** added code ***/
end.

repeat:
view frame f-menu1.
display menu1 with frame f-menu1.
do on endkey undo,leave:
choose field menu1 with frame f-menu1.
if frame-index = extent(menu1) then leave.
HIDE FRAME f-menu1. /*** added code ***/
run tstfrm2.p.
VIEW FRAME f-menu1. /*** added code ***/
end.
end.