1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question about Ctrl events

Discussion in 'Plugins' started by vefatica, Apr 28, 2011.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ---- 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
     

Share This Page