Internal variable _tctabs within TCExit

Apr 13, 2010
309
7
61
The Hague
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
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
_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?
 
Apr 13, 2010
309
7
61
The Hague
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
 

Attachments

  • TCEXIT.BTM
    1.5 KB · Views: 91
Last edited:
Apr 13, 2010
309
7
61
The Hague
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
 
May 20, 2008
11,411
99
Syracuse, NY, USA
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".
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
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?

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.
 
May 20, 2008
11,411
99
Syracuse, NY, USA
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.
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.
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
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.

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?
 
May 20, 2008
11,411
99
Syracuse, NY, USA
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?
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.
 
Apr 13, 2010
309
7
61
The Hague
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
 
Similar threads
Thread starter Title Forum Replies Date
rps For loop internal %_for_files variable? Support 2
D WAD Internal variable _cpu is undefined Support 2
H [4NT8] Internal Start-command and _? variable Support 5
G 4NT 9.02 _shell internal variable Support 50
fpefpe How to? free (internal) command Support 0
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
T Returning a value from internal Lua scripts to TCC Support 2
Joe Caverly Why does TCCRT return VIEW as an internal command? Support 6
F How to? Disable TCC's internal response to Alt-F4 Support 8
vefatica @EVAL's internal precision? Support 9
jfalch WAD internal "which" should check for FILEEXIST when using AppPaths entry Support 8
P Can't disable internal tar, at least in pipes Support 3
M Keywords for commands, functions, internal variables Support 3
E View (internal command) does nothing now Support 3
D Minor problem. Incorrect value internal var _dir_files Support 7
jbanaszczyk Alias for internal command Support 8
Joe Caverly Internal Lua and require Support 0
R Fixed Internal ZIP command fails to process multiple files Support 3
mikea Questions re: Internal ZIP command Support 5
epement no internal help for 'v' in TCmd v14 Support 6
R Override TCC internal commands Support 2
D Parsing an array variable to an array does not work Support 5
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
P Inserting string into a variable. Support 3
vefatica Setting array variable ignores leading spaces (and @execarray doesn't) Support 4
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
R Difference between TCC and CMD: variable names with hyphens Support 4
Joe Caverly Get a variable type Support 2
M How to set Path variable for non-executable file extensions in 4DOS Support 8
A How to safely print variable's value without quotes? Support 9
vefatica Array name in a variable? Support 3
nikbackm TCC 20 variable expansion bug Support 6
X How to set %_INIREAD result to variable Support 5
Charles Dye _USBS variable Support 2
BeechComer Debugger: how to set %1 variable? Support 3
Mordachai Variable followed by function constantly failing... Support 5
T Variable indirection for arrays Support 1
Mike Hall Unexpected "Variable loop" in IF condition Support 10
vefatica If there's no PATH variable ... Support 5
C Maximum length for a variable Support 8
fpefpe How to? Global variable set /v Support 4
I Change value of a variable while debugging Support 3
I "IF" command in a variable does not expand redirection variable name Support 0
J Variable setting regression in tcc17 ? Support 5
Jay Sage WAD Variable _LOGFILE Not Working Support 2
D Fixed Change in behavior of variable expansion between 16 and 17 Support 3
rps Fixed Using last argument variable ! Support 5
Jay Sage Brackets Around Variable Names Support 11
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
J Set environment variable from stdout of command Support 3

Similar threads