Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done TCC count internal variable

Jul
441
6
Add an internal variable which returns the number of TC Consoles running either in tabs or standalone.

A TCC instance count may be a better description.

Perhaps even a variable for a count of TCMD tabs running TCC and another variable for the number of standalone TCC instances.
 
Suggestion:
Add an internal variable which returns the number of TC Consoles running either in tabs or standalone.
A TCC instance count may be a better description.

In the meantime, could this function be of any use?
Code:
Function TEST=`%@execstr[ (tasklist /U"%1" tcc | echo %@lines[con:])]`
Where %1 is either empty (if you want all instances) or the username you want the number of running TCC instances from.

echo %@TEST[]
2
echo %@TEST[%username]
1
echo %@TEST[Maarten]
1


The result is not always accurate, though. This is caused by some weird behaviour of the @LINES function:
(but maybe it is good enough for your purposes):

2017-02-06 13_17_48-TCC.png



EDIT: Turns out to be caused by the "| ". It launches a fresh instance of TCC to execute the second part (I need more coffee :-).
The next function works better:
Code:
Function TEST=`%@execstr[ (tasklist /U"%1" tcc |! echo %@INC[%@lines[con:]])]`


echo %@TEST[Admin]
1

echo %@TEST[JohnDoe]
0
 
Last edited:
There's already the %_TCTABS variable (returns the # of tab windows).
Not useful in a standalone TCC sessions or for knowing how many of the TCTABS are running TCC, some may be running other things such as Windows CMD.

I have several alias's that perform different exiting tasks and they need to determine how many TCC instances are running.

An internal variable would be cleaner and presumably faster than the function above.

Bottom line: %_tctabs doesn't meet the need. Thus the suggestion to add an internal variable which returns the number of TC Consoles running either in tabs or standalone. Just saying.

While we're on the subject of addition for future TCC version.

It would also be useful to have internal variables to use in determining global command history, directory history, alias and user function lists status within a TCC session.
 
Last edited:
An internal variable would be cleaner and presumably faster than the function above.

Ok, just for the fun of it (using [title] ) :

Code:
set _TEST=%%@execstr[ (tasklist tcc ^|! echo %%@INC[%%@lines[con:]])]

timer on & echo %_TEST & timer off
Timer 1 on: 22:12:06
3
Timer 1 off: 22:12:06  Elapsed: 0:00:00,07
 
Also just for fun.
Code:
v:\> timer echo %_tcccount
Timer 1 on: 17:39:00
17
Timer 1 off: 17:39:00  Elapsed: 0:00:00.00
 
Maarten, yours is quite fast if you put it into a variable and don't care about the user.
Code:
v:\> set __tcccount=`%@execstr[ (tasklist tcc |! echo %@INC[%@lines[con:]])]`

v:\> timer echo %__tcccount
Timer 1 on: 21:00:22
9
Timer 1 off: 21:00:22  Elapsed: 0:00:00.00
 
Code:
v:\> set __tcccount=`%@execstr[ (tasklist tcc |! echo %@INC[%@lines[con:]])]`
[...]
Timer 1 off: 21:00:22  Elapsed: 0:00:00.00

Well, what do you know ... it was the timer on & timer off sequence that consumed most of the time ...
Nice work with the backquotes, btw. Makes it look much cleaner!


Shouldn't this be even faster, then?:
set __tcccount=`%@execstr[tasklist tcc | echo %@lines[con:]]`

("|!" becomes "|" ; faster according to the helptext. This also eliminates the cause for the extra @inc )

Thanks Vince! Learned a lot today.
 

Similar threads

Back
Top