Question about Ctrl events

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
I have an old plugin, GENBREAK, a one-liner ...

Code:
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
It has served me well until lately. When I use it like this (pressing "q"):

Code:
ON BREAK ( ECHO foo & QUIT )
DO FOREVER
    DELAY /M 1
    SET key=0
    INKEY  %%key
    SWITCH %key
        CASE q
            GENBREAK
    ENDSWITCH
ENDDO
it's iffy whether or not I see "foo" (maybe 60/40 in favor of not seeing it). Why is it iffy? And how might I improve GENBREAK so it's reliable in this situation? Thanks.
 
#2
On Thu, 28 Apr 2011 23:16:12 -0400, you wrote:

|Code:
|---------
|ON BREAK ( ECHO foo & QUIT )
|DO FOREVER
| DELAY /M 1
| SET key=0
| INKEY %%key
| SWITCH %key
| CASE q
| GENBREAK
| ENDSWITCH
|ENDDO
|---------
|it's iffy whether or not I see "foo" (maybe 60/40 in favor of not seeing it). Why is it iffy? And how might I improve GENBREAK so it's reliable in this situation? Thanks.

I should have added that the batch file always ends.
 
#3
---- Original Message ----
From: vefatica
...
|| it's iffy whether or not I see "foo" (maybe 60/40 in favor of not
|| seeing it). Why is it iffy? And how might I improve GENBREAK so it's
|| reliable in this situation? Thanks.
|
| I should have added that the batch file always ends.

If the batch file is run in a transient or piped-to instance of TCC, the issue could be timing: the instance disappears before the message in ECHO becomes visible, due to buffering.

Regardless, I think you could use "ON CONDITION" without the need for GENBREAK!
--
Steve