flow of program control

Posted by Admin on 01-Apr-2009 04:52

  ------
|      |
|  W1  |----------------
|      |                |   
  ------                 |   
    |                    |   
    |                    |   
    |                  ------
    |                 |      |
  ------              |  W2  |
|      |             |      |
|  W4  |              ------
|      |                |    
  ------                 |    
                         |    
                         |    
                       ------ 
                      |      |
                      |  W3  |
                      |      |
                       ------

I have a question regarding the flow of control. In the above diagram. "W1" is a Window which contain the menu.

Scenario 1

I call W2 from W1 and W2 calls W3. Now when I close W3, control is passed to the statement following the "run W3" in W2. This is what I expected and it works fine.

Scenario 2

I call W2 from W1 and W2 calls W3. Now I don't close W3 but open W4 from W1. After this if I close W3 control does not go to the statement following the "run W3" in W2.

All the calls are non-persistent. Is my expectation / style of coding wrong for scenario 2? The window W3 remains the memory but not visible in this case.

But if I close W4 and then W3, control goes the way I expect.

Could someone please explain this behaviour?

Thanks

Joel

All Replies

Posted by Admin on 01-Apr-2009 05:02

Is my expectation / style of coding wrong for scenario 2?

Looks like a yes...

Multi-Window applications should only use a single WAIT-FOR statement. Once that statement is reached all remaining code runs in or from event handlers (Triggers) - like the menu choose triggers in W1.

The normal appbuilder templates have something (sometimes in an include file) like

IF NOT THIS-PROCEDURE:PERSISTENT

  WAIT-FOR CLOSE OF THIS-PROCEDURE .

In your sample - without using persistent windows - you'd have multiple WAIT-FOR statements active. That is usually a bad thing - with the only exception of modal dialog windows.

While W4 is open, the user sees W3 and possibly W2. Did you try if there are any issues when the user actually clicks buttons or similar in W2 and W3? That may be the case because you may be using multiple WAIT-FOR blocks. This can explain why closing W3 does not "remove" the W3.w from memory. This is because W3's ON CLOSE OF {&WINDOW-NAME} trigger does not execute and does not run a APPLY "CLOSE" TO THIS-PROCEDURE somewhere.

First step to be better/more solid solution would be to use PERSISTENT procedures in multi-window applications.

Any reason for not using them?

Posted by Admin on 01-Apr-2009 05:08

In your sample - without using persistent windows - you'd have multiple WAIT-FOR statements active. That is usually a bad thing - with the only exception of modal dialog windows.

In your case with using modale dialog windows, the user would not be able to close W3 while W4 would be open.

Nachricht geändert durch Mike Fechner

Posted by Admin on 01-Apr-2009 06:25

Hallo Mike vielen dank fuer deine antwort.

This thread is closed