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

Adaptive toolbar buttons in TCmd

Discussion in 'T&T - Scripting' started by nchernoff, Jun 4, 2008.

  1. nchernoff

    nchernoff Administrator
    Staff Member

    Joined:
    May 16, 2008
    Messages:
    42
    Likes Received:
    2
    Migrated From JP Software Wiki

    I run the JP command processors on a couple machines that have different sets of software installed. I wanted to use the same startup files on both machines, yet I didn't want to have useless buttons on the Take Command toolbar. My solution was to configure the toolbar dynamically on startup.

    A variation of this technique could be used for using the TCmd toolbar as part of a dynamic "menuing system".

    Programming technique

    I check for each software package I'm interested in, and if it is found, then I create a toolbar button for it. I set the nb environment variable to keep track of the number of buttons I have created so far. The @INCR[] function acts like a ++nb in the C language, incrementing and then returning the value of the nb variable.
    Code:
    
    
    function incr `%@exec[@set %1=%@inc[%1]]%[%1]`
    
    iff %_CMDPROC eq TCMD32 then
        iff %_4ver ge 8.0 then
            TCTOOLBAR /C
        endiff
    
        set nb=0
    
        :: to use & or %+ in the TCTOOLBAR commands
        ::
        setdos /x-5
    
        set _exe=%@search[i_view32.exe,%PATH;%SystemDrive\bin\IrfanView]
        iff defined _exe then
            TCTOOLBAR %@incr[nb] 2 IrfanView @"%_exe"
            unset _exe
        endiff
    
        iff isalias eps then
            TCTOOLBAR %@incr[nb] 2 Eps @eps
        endiff
    
        set _exe=%@search[ntfy_cd.exe,%PATH;%ProgramFiles\CD-R\NotifyCD;%ProgramFiles\NotifyCD]
        iff defined _exe then
            TCTOOLBAR %@incr[nb] 2 NotifyCD @"%_exe"
            unset _exe
        endiff
    
        set _exe=%@search[msdev.exe,%PATH;%SystemDrive\VS\Common\MSDev98\Bin]
        iff defined _exe then
            TCTOOLBAR %@incr[nb] 2 VC6 @"%_exe" /Y3
            unset _exe
        endiff
    
    :: [snip several other buttons]
    
        :: Clear out any extra buttons in previous versions of TCmd
        ::
        iff not %_4ver ge 8.0 then
            do qq = %@inc[nb] to 31
                TCTOOLBAR %qq
            enddo
            unset /q qq
        endiff
        unset /q nb
    
        setdos /x+5
    endiff
    
     

Share This Page