Welcome!

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

SignUp Now!

Dynamicaly configuring the toolbar

Apr
318
7
I would like to add/remove buttons to/from the toolbar depending on the presence of software on my system.

After hours of trying different versions I still haven't found the correct syntax.

For example:
I want my TCSTART to contain generic code only and run an extra batch with specific initialisation in a separate console for Perl.

Something like

Code:
IFF ISFILE C:\Perl\bin\perl.exe THEN
[INDENT]SET tab=Consoles
SET btn=n
SET flg=256
SET icn=C:\Perl\bin\perl.exe
SET ttl=Perl5
SET dir=C:\Develop\Perl
SET cmd=%ComSpec StartPerl.BTM
TCTOOLBAR %tab %btn, %flg, %icn, %ttl, %dir, %cmd
[/INDENT]ENDIFF

What is the correct syntax? Why does the Help text show the first two parameters separated by spaces and the rest by comma's? The docs describe the value of the flags to be both zero-based and 256-based. Which is correct or what is the difference? If different combinations of parameters accomplish different things, which is for what?

Please help.
 
I would like to add/remove buttons to/from the toolbar depending on the presence of software on my system.

I think that the way it's supposed to work is:

The first parameter, "tab", is optional; the command knows you've supplied it because it's terminated with a space, not a comma. This parameter is supposed to indicate the toolbar tab you want to modify -- either the section name in the .INI file or the title as set by a Title= directive, I'm not clear which. Either way, it should be a string. If you don't supply this parameter, TCTOOLBAR should assume the currently selected tab.

The second parameter (or first, if "tab" isn't present) is the number of the button to modify: 1 for the first button on the tab, 2 for the second button, and so on. This parameter must be an integer; TCTOOLBAR aborts with an error if it isn't. The remaining parameters are as documented.

BUT: I don't think that the command parser is actually working as intended. If you do supply the optional "tab" parameter, the command doesn't recognize it and gorks because it's expecting an integer. If you don't supply it, the command incorrectly defaults to a null string rather than the section name (or title?) of the current tab. If you use TCTOOLBAR with the /U option and no "tab" parameter, you'll see that your button definition is written to the .INI file in a section with an empty [] header.
 
Thank you Charles, for taking the time to respond. It does feel lonely sometimes, without anyone to spar with.

IMHU The documentation goes from being unclear via contradicting itself to downright wrong.
TCTOOLBAR [/C /R file /U /W file] tab button [,flags, icon, title, directory, command] is at least unclear.

If I try to put your remarks and my experience in a still imperfect but better understandable definition of the syntax,
it reads something like this:

Code:
TCTOOLBAR /C | 
          /R filename <FILENAME>| 
          /U | 
          /W filename<FILENAME>| 
          [ | nTabNr | strTabName ] nButton 
          [, nFlags, [ strIconSpec, <ICONFILENAME>] strTitle, [strPath, ] strCommand ]
Which does not look very elegant. It also means:
- no parameters is an error.
- "/U filename" <FILENAME>is an error.
among other things.
But still, I'm unsure about that most important last line of the syntax def.
I think in some cases the path is optional too. Let's experiment.
Code:
:: Clear the TB
TCTOOLBAR /C
:: Load a def that's known to work. (See example below)
TCTOOLBAR /R TB_def1.INI
:: Now, let's add a button, not mentioning any tabs.
TCTOOLBAR 3, 261, "Wide Dir", "C:\", "DIR /W" Enter
TCTOOLBAR 3, 261, Wide, "C:\", "DIR /W" Enter
TCTOOLBAR 3, 261, Wide, C:\, "DIR /W" Enter
:: Okay, forget the darn' separator
TCTOOLBAR 3, 256, "Wide Dir", "C:\", "DIR /W" Enter
TCTOOLBAR 3, 256, Wide, "C:\", "DIR /W" Enter
TCTOOLBAR 3, 256, Wide, C:\, "DIR /W" Enter
:: Looking at an example from an earlier version of TCMD,
:: I changed the flags again.
TCTOOLBAR 3, 2, "Wide Dir", "C:\", "DIR /W" Enter
TCTOOLBAR 3, 2, Wide, "C:\", "DIR /W" Enter
TCTOOLBAR 3, 2, Wide, C:\, "DIR /W" Enter
:: Still, no luck.
:: In the forementioned example the parameter pattern was:
 <NUMBER> <NUMBER><STRING>"<STRING>"
 
:: Let's try that, skipping the dir parameter
TCTOOLBAR 3, 2, "Wide Dir", "DIR /W" Enter
TCTOOLBAR 3, 2, Wide, "DIR /W" Enter
TCTOOLBAR 3, 2, Wide, `"DIR /W" Enter`
:: It seems nothing works
In all of the above cases the result is (1) no errormsg (2) the first button disappears
and (3) the saved definition is left unchanged (4) any further attempt removes
the toolbar altogether.

Something else I noticed.
The TCTOOLBAR /R option is not additive like SET /R or ALIAS /R.
If you create two files with the folowing content:

Code:
 TB_def1.INI:
  [Toolbar1]
  Title=Tab1
  B1=257,,Clear screen,,,"CLS" Enter
  B2=261,,MyDir,,,"PDIR" Enter

Code:
 TB_def2.INI:
  [Toolbar2]
  Title=Tab2
  B3=261,,Desktop,,,"*CDD /T dt:" Enter
  B4=261,,Development,,,"*CDD /T dev:" Enter

TCTOOLBAR /C
Clears everything

TCTOOLBAR /R TB_def1.INI
Creates the toolbar as expected. Let's create an INI-file.

TCTOOLBAR /W first.ini
The result reads:

first.INI:
[Toolbar1]
Title=Tab1
B1=257,,Clear screen,Algemeen,,"CLS" Enter
B2=261,,MyDir,Algemeen,,"PDIR" Enter
That's okay too. Now, let's load the definition of the second bar.

TCTOOLBAR /R TB_def2.INI
GUI: we get three (!) tabs: "Untitled", "Tab2" and "Tab1".
If we write out the definition like so:

TCTOOLBAR /W second.ini
That second file has the following content:

second.INI:
[Toolbar1]
Title=Untitled
[Toolbar2]
Title=Tab2
B1=261,,Desktop,,,"*CDD /T dt:" Enter
B2=261,,Development,,,"*CDD /T dev:" Enter
The second (non-overlapping) definition has more or less destroyed the first.
Notice the button numbers in the second definition have been changed too.


So, back to my original posting.
Ideas anyone? Does anybody have a single working command? That might at least give me
a starting point. Some solid ground to base further experimentation on.
 
<filename><filename><iconfilename><filename><number><number><string><string>Does anybody have a single working command?

I sure don't. But searching the forum for 'TCTOOLBAR' shows someone else asking the same questions you are, about two months ago....

</string></string></number></number></filename></iconfilename></filename></filename>
 
> I would like to add/remove buttons to/from the toolbar depending on the
> presence of software on my system.
>
> After hours of trying different versions I still haven't found the
> correct syntax.

The reason you couldn't find the right syntax is because there is an error
in the documentation (it's missing one argument). After correcting that I
found a bug in the TCTOOLBAR code that could trigger depending on the
existence of one of the optional arguments. I should have a corrected build
uploaded in the next day or two.

Rex Conn
JP Software
 

Similar threads

Back
Top