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

TCC count internal variable

Discussion in 'Suggestions' started by rps, Feb 6, 2017.

  1. rps

    rps

    Joined:
    Jul 6, 2008
    Messages:
    202
    Likes Received:
    3
    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.
     
  2. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    Suggestion:
    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
     
    #2 MaartenG, Feb 6, 2017
    Last edited: Feb 6, 2017
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,854
    Likes Received:
    83
    There's already the %_TCTABS variable (returns the # of tab windows).
     
  4. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    .. in the current TCMD.
    If you have multiple TCMD's running, it will miss the tabs in those.
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,854
    Likes Received:
    83
    True, but I've never seen a case where there was a good reason to be running multiple TCMD sessions.
     
  6. rps

    rps

    Joined:
    Jul 6, 2008
    Messages:
    202
    Likes Received:
    3
    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.
     
    #6 rps, Feb 12, 2017
    Last edited: Feb 12, 2017
  7. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    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
    
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,935
    Likes Received:
    30
    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
    
     
  9. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    Haha, that is at least 7 times funnier :-)
    Plug-in?

    (Didn't know about timer <command>; thanks for that!)
     
  10. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,935
    Likes Received:
    30
    Yes, plugin.
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,935
    Likes Received:
    30
    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
     
  12. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    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.
     
  13. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,854
    Likes Received:
    83

Share This Page