Getting Quote Characters into a Toolbar Tab

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jun 2, 2008
284
1
Newton, MA
#1
How can one get quote characters into the text sent to the current tab in a toolbar button? I have a number of buttons that use the variable "_selected" to enter a selected file name into a command. For example, a button with the label "ED" has the following command definition:

esc "edit %_selected" enter
However, this fails when the selected file name has a space character (I **NEVER** create files with spaces in the name, but, unfortunately, others do), so I tried defining the command as follows:

esc "edit %@quote[%_selected]" enter
However, the button command seems to turn into something like

esc "edit "file name"" enter
and the toolbar processor can't handle that. As far as I can tell from the documentation, there is no alternate character to the quote character for the keystroke definition. A similar problem must arise with the KEYSTACK command.

I hope that I'm overlooking something simple and obvious.
 
Jun 2, 2008
284
1
Newton, MA
#3
Use two double quotes to send a single one (see the online help for KEYSTACK).
That will work for putting a quote character manually into a string. How do I do that programmatically. How do I get the @quote function to produce the appropriate double quotes?
 
Jun 2, 2008
284
1
Newton, MA
#4
The KEYSTACK syntax appears not to work. Its help says the following:

For example, to insert the string abc "def"

keystack "abc " "" "def" ""
So I copied that into a definition for the button TEST:

esc "abc " "" "def" ""
When I click on that button, the following appears on my command line:

TCC(17.00.53): C:\>abc " def""
The KEYSTACK command does work as advertized:

TCC(17.00.53): C:\>keystack "abc " "" "def" ""
TCC(17.00.53): C:\>abc "def"​
 
Jun 2, 2008
284
1
Newton, MA
#5
I solved part of my problem. When the button ends with "enter" to run a command line, I can include

%%@quote[%_selected]
and the @quote function will be evaluated and run. However, this approach doesn't work (or works less well) with commands that just populate the command line, such as my REN button, whose definition is

esc "ren %_selected "
When used with a file name containing spaces, I would like to see the partial command as

c:>ren "file name" (line ends with a space)
instead of

c:>ren %@quote[file name]
I guess that if no other solution were possible, I could live with that, but it would be nice if KEYSTACK and the buttons could use alternative string delimiters, such as a single quote (apostrophe) as well as a double quote (quote).
 
Jun 2, 2008
284
1
Newton, MA
#7
Yes, it does work, but that is not what the help for KEYSTACK says one is supposed to use. The help says, quote, to insert the string

abc "def"
use

keystack "abc " "" "def" ""
I understand that to mean that one is supposed to enter two quotes as the key name for a quote character.

Your example works, I think, because the first pair of quotes generates a (single) quote character, then the unquoted string generates the string foo, even though that violates the rules, and then the final pair of quotes generates another (single) quote character.

When one enters the incorrect command

keystack abc
the characters "abc" are sent to the command line, even though there are no quotes. I guess that's because the letters are the names of their characters. So the following command does the same thing:

keystack a b c​
 
Jun 2, 2008
284
1
Newton, MA
#8
I can confirm that the quotes in a toolbar button now work as they do with the KEYSTACK command.

I still have not figured out how to get quote characters into the string in a programmable way.
 
Jun 2, 2008
284
1
Newton, MA
#9
Built-in functions are evaluated in toolbar button definitions. So, for example, the following button definition

esc "echo %@left[2,%_selected]" enter
with the string "Normal" selected (without the quotes), will produce the command line

echo No
I defined a user function KEYSTKSTR that would convert a selected file name into the proper KEYSTACK-like format for a button. I changed the button definition to

esc "echo %@keystkstr[%_selected]" enter
Here is what keystkstr produces with the same text selected:

TCC(17.00.54): C:\temp>echo %@keystkstr[Normal]
Normal

When I click the toolbar button, however, I get the command ECHO followed by nothing. So it appears that the user-defined function is not being evaluated.

Rex, is that WAD?
 
#10
Further experimentation shows that plugin functions also do not work in toolbar button definitions. They do work with KEYSTACK.

TCC(17.00.54): C:\>keystack "echo %@fact[10]" enter

TCC(17.00.54): C:\>echo 3628800
3628800

But the button definition

esc "echo %@fact[10]" enter

produces the following when clicked

TCC(17.00.54): C:\>echo
ECHO is OFF
 
#12
WAD. The toolbar buttons are being parsed and expanded by Take Command, not TCC. User defined functions and plugins are TCC features, not TCMD.
OK. That makes sense. It does leave me wondering why built-in TCC functions--such as @left, which I tested--do work. Did you duplicate those functions in TCMD?

So, my next suggestion/request (which I can submit in feedback if you report that it is feasible) is to add another variable to the _selected presently available. It could be called something like _selected_file and would do what _selected does except that it would included the @quote functionality (after processing the string-delimiting quote characters). That is, it would add surrounding quote characters to the string of selected text when it is potentially a file name containing spaces.

Of course, the @quote function could be used if there were an alternative to the quote character as a string delimiter.
 

rconn

Administrator
Staff member
May 14, 2008
10,205
86
#13
OK. That makes sense. It does leave me wondering why built-in TCC functions--such as @left, which I tested--do work. Did you duplicate those functions in TCMD?
TCMD calls takecmd.dll, which has the functions (and internal variables). But it doesn't try to run an internal TCC session.

So, my next suggestion/request (which I can submit in feedback if you report that it is feasible) is to add another variable to the _selected presently available. It could be called something like _selected_file and would do what _selected does except that it would included the @quote functionality (after processing the string-delimiting quote characters). That is, it would add surrounding quote characters to the string of selected text when it is potentially a file name containing spaces.

Of course, the @quote function could be used if there were an alternative to the quote character as a string delimiter.
It wouldn't be straightforward, but it might be possible. Go ahead and submit it to Feedback.