One Wait-For Req for Chui?

OK. I'll start this area off...
I maintain an app where in many cases there are 2 wait-fors active at the same time. This seems to work for the most part but I am seeing certain conditions which result in a frame not getting hidden and interface triggers not firing. Is it a requirement that only one wait-for be active at any given time in Chui? Is it OK under certain conditions?
 

Chris Kelleher

Administrator
Staff member
Hi Chris-

You should only ever use one WAIT-FOR in a procedure. Having multiple WAIT-FOR statements active at a time can cause problems, such as the ones you stated.

I have also worked on a GUI application where there was a wait-for in the main block. There was another wait-for that would be active after the user clicks on the update button, which would wait for the user to click the OK button. One big problem would be if the user clicked update and then closed the window, Progress would complain with a run-time error message about the wait-for (in the main block) being terminated.

Remember also that ChUI and GUI are different and shouldn't be mixed just like event-driven (enable/wait-for) and procedural programming (update/prompt-for) shouldn't be mixed. I have seen many problems with old ChUI code being slowly mixed with event-driven code that can causes headaches as well.

Hope this helps.

-Chris Schreiber
 
Thanks much Chris but are you saying

1. two wait-fors can be active as long as they are in separate procedures?
or
2. two wait-fors should never be active?
 

Chris Kelleher

Administrator
Staff member
It depends on if you are developing GUI or ChUI. If you are only working in character mode, the one-wait-for rule is somewhat less significant. There is only one window visible at any time in ChUI, and it is the entire terminal screen. So for ChUI, I would say one wait-for per procedure is fine.

The concept of the one wait-for for the session is primarily significant in GUI where one can minimize windows or have multiple windows displayed simultaneously. In those circumstances, it is far too easy to close the initial procedure and leave un-parented wait-fors hanging out in error-error land.
 
S

Serj HAMMER

Guest
Multi WAIT-FOR in ChUI

Hello, Chris!
I am writing app in ChUI and EVENT-DRIVEN mode. And have suceess worked many (I don't known how match) WAIT-FOR's at the same time. It is not necessarily to put each WAIT-FOR in separate procedure. You may put one WAIT-FOR into the trigger of another WAIT-FOR, but You must strongly controll frame, where triggers from each WAIT-FOR fired.

If You have multi active frames at the screen when WAIT-FOR started - use FOCUS in WAIT-FOR phrase to select first-focuset widget.

But I have one problem in this model.
It is for You and for everyone:
We have 2 WAIT-FOR statements. External, and Internal (in the trigger of external).
When internal WAIT-FOR finished and trigger-procedure finished - I lose focus in External WAIT-FOR.

Example:
DEFINE BUTTON b1.
DEFINE BUTTON b2.
DEFINE FRAME f1 b1 WITH TITLE "Ext".
DEFINE FRAME f2 b2 WITH TITLE "Int".

ON CHOOSE OF b2 IN FRAME f2 DO:
MESSAGE "show 2" VIEW-AS ALERT-BOX.
END.
ON CHOOSE OF b1 IN FRAME f1 DO:
MESSAGE "start 1" VIEW-AS ALERT-BOX.
DO ON ENDKEY UNDO, LEAVE:
WAIT-FOR END-ERROR OF FRAME f2 FOCUS b2.
END.
HIDE FRAME f2.
MESSAGE "finish 1" VIEW-AS ALERT-BOX.
END.
ENABLE b1 WITH FRAME f1.
DO ON ENDKEY UNDO, LEAVE:
WAIT-FOR END-ERROR OF FRAME f1 FOCUS b1.
END.
HIDE FRAME f1.

P.S. In real life it is more complicated. It is only example.
But when I have a lot of frame's at the screen - I realy lose LAST ACTIVE FRAME.
Is any-body know how fight with PROGRESS frame stack?

Message imported from PEG email list
 
B

Brane

Guest
wait-for & focus

hello,
I am keeping focus on right place using this procedure
instead wait-for :

procedure wait4close .
def var h_focus as handle no-undo.
h_focus = focus . /* save focus */

wait-for "close" of current-window .

if valid-handle(h_focus) /* restore focus */
then focus = h_focus.
end procedure.

Have a nice day,
Brane


Message imported from PEG email list
 

Serj HAMMER

Junior Racer
Thank You, Brane!

Thanks, Brane!
You are FIRST, who give me usable answer.
All other answers (PEG, some of support services, etc.,..)
only say, that using multi wait-for in character mode is not rules.

And You are really help me.
Thank You very much!
 
Top