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

Internal variable _tctabs within TCExit

Discussion in 'Support' started by djspits, Jun 12, 2014.

  1. djspits

    Joined:
    Apr 13, 2010
    Messages:
    189
    Likes Received:
    2
    For the observant reader: I withdrew a recent posting on TCExit because I misdiagnosed a problem. Thanks for pointing it out. Here is why:

    From the helpfile:

    _TCTABS returns the current number of Take Command tab windows (or 0 if TCC is not running in Take Command).

    It appears that _TCTABS (and _TCTAB) is always zero during the execution of TCExit. Other internal variables still hold valid values. Maybe the console is considered to be closed already.

    I was hoping to use this value to trigger some action on closing the *last* TC console. But now I'm out of luck because I can't discriminate between "last console" and "not running in TC".

    Could the variable be decremented after TCExit?
    If not, how could I keep track of the number of consoles?

    Regards, DJ
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,855
    Likes Received:
    83
    _TCTABS isn't really a TCC variable, it's a TCMD status. TCC queries TCMD to get the number of active tab windows; it isn't affected by a TCEXIT.

    I can't reproduce your issue here -- if TCEXIT is running, then the console window is still alive and TCMD returns "1".

    Exactly how are you exiting TCC?
     
  3. djspits

    Joined:
    Apr 13, 2010
    Messages:
    189
    Likes Received:
    2
    Thank you for your reply, Rex.

    I have assigned Alt+X to File | Close tab and Alt+N to File | New tab
    I have CloseIfNoTabs set to No.

    Normal operation: I keep TCMD running and use the keyboard to open consoles for various tasks and closing them when ready. So, on the first Alt+N the toolbar is initialized and after the final Alt+X the toolbar is cleared.

    I include my TCExit.BTM

    Regards, DJ
     

    Attached Files:

    #3 djspits, Jun 13, 2014
    Last edited: Jun 16, 2014
  4. djspits

    Joined:
    Apr 13, 2010
    Messages:
    189
    Likes Received:
    2
    I wrote the values of _tctabs and _tctab to a textfile from within tcexit. As shown in my updated upload above. Both values are zero.

    I am running TCC 16.03.52 x64 Windows 8.1 [Version 6.3.9600]

    Can anyone reproduce my findings?

    DJ
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,939
    Likes Received:
    30
    It apparently depends on how you close the tabs. I put this in TCEXIT.BTM
    Code:
    echo %_TCTABS %_TCTAB > pid%_PID.txt
    When I closed three tabs with TCC's "EXIT" command the files contained "3 1", "2 1", and "1 1".

    When I closed three tabs by X-ing them individually I got "0 0" in all three files.

    I could rationalize that ... TCMD first detaches the consoles and then signals the TCCs to close. Is that WAD?

    And (maybe no surprise) if I X TCMD itself, all the files contain "0 0".
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,855
    Likes Received:
    83
    WAD -- when you X the tab (or the TCMD window), you destroy the tab window immediately. The hidden consoles aren't detached (yet), but there's no tab window left for them to query.

    There really isn't any other way to handle this, unless TCMD requires that all tab windows be running TCC so it can communicate with the console session.
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,939
    Likes Received:
    30
    Hmmm! TCMD handles tabbed apps exiting on their own (EXIT command) or even being killed in TaskMgr (CMD too). TCMD gracefully closes the tab. Couldn't the tab's "X" send a message to the app (or whatever's done to get it to exit) and let that other mechanism take over to close the tab? Or maybe you can't alter what the "X" does. I am only curious.
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,855
    Likes Received:
    83
    TCMD used to do that, but you complained (loudly and often!) about delays in closing the tab window -- i.e., when TCC was running a lengthy TCEXIT, or when the app simply ignored the close message (which happens more often than you'd think). Do you want me to change it back to the original behavior now?
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,939
    Likes Received:
    30
    I don't think that was me. But if those scenarios are likely, you have a trade-off. Either way, it's not likely to concern me. As I said, I was just curious about the mechanism.
     
  10. djspits

    Joined:
    Apr 13, 2010
    Messages:
    189
    Likes Received:
    2
    So clicking "X" is equivalent to the menu option Tab | Close. I was hoping that the latter would be a "graceful" alternative like EXIT. I think I understand. All this means that _tctab has the correct value in a console that has lost its window (zero) and that _tctabs is undefined in such circumstances. Only the EXIT command keeps the connection to TCMD alive long enough. I guess I could rig the Alt-X key assignment to somehow issue the command instead of closing the window but I cant stop the user from clicking "X". I could try to keep my own global counter,... but there's no point because even if I get the count right, I can no longer clear the TCMD toolbar from TCC which was the whole purpose of keeping the count.

    Back to the drawing board.
    Regards, DJ
     

Share This Page