Wait-for terminated

Posted by Patrick Tingen on 03-Mar-2017 03:02

I have a program that gives me a "wait-for terminated" error. I have tried to reproduce what I have done in a small program. Basically, a lot of stuff goes on on the screen and when the user presses "ESC" the program should terminate. But when I press ESC, I get this:

Clearly I am doing something wrong. When you run my test program you see a button. Just press it. And then press ESC within 4 seconds. 

Test program can be found at http://pastebin.com/NnTCCyRg 

All Replies

Posted by Laura Stern on 03-Mar-2017 07:35

Yes, this is a very simple program EXCEPT for that unusual PROCESS EVENTS loop in the button CHOOSE event.  Why are you doing that?

Anyway, I'm at home and can't run this right now.  But I suspect that when you hit ESC, the frame is actually going away while you're in the middle of that loop!  

Posted by Patrick Tingen on 03-Mar-2017 07:53

The idea of the PROCESS EVENTS is to avoid 'eating' events as they happen. What I am doing in the original program is some animation that should be escapable by the user, hence the PROCESS EVENTS commands.

The ESC hit should fire the ON END-ERROR trigger, which in turn does APPLY 'close' TO THIS-PROCEDURE.

That, in turn, should fire the WAIT-FOR since that one is waiting for just that to happen.

I share your suspicion, but I don't feel like I am doing something wrong here. But computer says 'no' anyway....

Posted by Laura Stern on 03-Mar-2017 08:14

Just as an experiment, try taking off the AUTO-GO on the button and see if it changes anything.

Posted by Fernando Souza on 03-Mar-2017 09:46

I can't reproduce the error with the provided code. But I don't see the WAIT-FOR getting satisfied either so there is something wrong there. The PROCESS EVENTS statement is causing some issue for sure. We will look into that.

As a workaround, you can try setting a variable in the END-ERROR trigger instead of doing the apply close when you are in that REPEAT loop (will need another variable for that). Then once we get out of the REPEAT loop (due to ENDKEY),  you can check if the variable was set and then apply close. Then you avoid the window going away via PROCESS EVENTS.

Posted by Patrick Tingen on 06-Mar-2017 05:00

[mention:7d0b3270407347e7b620898aa84c2f5f:e9ed411860ed4f2ba0265705b8793d05] Surprised by your claim I tried it via PDS and got no error. Tried again via GUI editor and again no error (although window remained active instead of disappearing).  Try it via the AppBuilder and you will see the error. I tried it in 11.6, but 10.2 gives the same result (and so does 9.1)

Posted by Stefan Drissen on 06-Mar-2017 05:37

Your error is coming from the AppBuilder run code

--> adecomm/_runcode.p at line 696

This contains (stripped down):

REPEAT
  ON QUIT       , LEAVE
  ON STOP   UNDO, LEAVE
  ON ERROR  UNDO, LEAVE
  ON ENDKEY UNDO, LEAVE
:
  ASSIGN
     DEFAULT-WINDOW:SENSITIVE   = TRUE
     CURRENT-WINDOW             = DEFAULT-WINDOW
     .

  RUN VALUE( p_RunFile ) PERSISTENT SET p_hProc.
  hCurWin =  p_hProc:CURRENT-WINDOW.

  WAIT-FOR    
     WINDOW-CLOSE,CLOSE OF p_hProc OR
     WINDOW-CLOSE,CLOSE OF hCurWin
     .
END. /* REPEAT */

p_hproc and hcurwin are no longer valid when exiting from your window.

Posted by Fernando Souza on 06-Mar-2017 08:37

When you run the .w via the AppBuilder, the code is executed persistently and the wait-for is happening outside of your code. Without looking at it, I am assuming the procedure/window is going away sooner than normal due to the PROCESS EVENTS.

This thread is closed