Getting Quote Characters into a Toolbar Tab

Jun 2, 2008
376
2
Newton, MA
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
376
2
Newton, MA
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
376
2
Newton, MA
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
376
2
Newton, MA
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
376
2
Newton, MA
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
376
2
Newton, MA
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
376
2
Newton, MA
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?
 
Jun 2, 2008
376
2
Newton, MA
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
 
Jun 2, 2008
376
2
Newton, MA
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
12,340
149
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.
 
Similar threads
Thread starter Title Forum Replies Date
C history is getting deleted under unknown circumstances Support 9
MikeBaas V19 getting non-responsive Support 1
WadeHatler Just started getting a message about Cloud Storage every time I start TCC 19 Support 3
M How to? List path getting short file and directory names... Support 10
mfarah How to? Getting pdir to display relative paths. Support 2
M Why is this function getting these results in these circumstances? Support 6
R Command history getting reloaded Support 16
M Programmatically getting the console width in character Support 18
fpefpe escapes getting into program Support 10
D Double Quote in TC Tool Bar Button Command line Support 3
aedthuio TCC: No closing quote Support 2
rps Fixed V17 @name adding quote (") to result Support 5
vefatica WAD HISTORY /R, No closing quote? Support 10
J Fixed Filename completion does not quote filenames containing ^ Support 1
M How to? Missing closing quote: What am I doing wrong???? Support 7
C CMD's "nested quote" syntax Support 3
C Can't remove leading quote from a string Support 2
R WAD Unusable state when using Chinese characters Support 3
C TEE command appending null characters to output Support 6
D Regexes and escape characters Support 5
vefatica Quoting file names with special characters? Support 7
vefatica How to? Add real <ESC> characters with TPIPE Support 2
C Erase all characters left or right from cursor location Support 2
J Escaped Characters and Variables Support 2
Joe Caverly Unicode, Codepage 437, and line characters Support 3
gschizas Fixed Using codepage 65001 (UTF-8) breaks non-ASCII characters Support 8
vefatica Display of special characters in aliases. Support 25
J Python: TCC command line parsing removes '=' equal sign characters Support 4
C filemasks over 172 characters fail Support 5
redwdc TCC.exe opens to 11 characters x 3 rows Support 1
G Selection characters with mouse double-click Support 3
R Function #IDOW returns only 2 characters Support 10
krischik WAD Tee printing Chinese characters Support 7
Alexander How to? how can I use Cyrillic characters in the Echo command? Support 8
jadaml Echo unicode characters from UTF-8 Batch files? Support 1
V Fixed CD ~ has trash characters in it Support 5
S International characters - TYPE vs %@LINE function Support 5
vefatica Fixed Escaping special characters Support 1
M Problem with Extended Search and non-ASCII characters in directories names Support 3
A How to? PhraseExpress autotext/autocompletion printing unexpected characters Support 4
thedave WAD Unable to type various characters using Windows 8's onscreen keyboard Support 7
JohnQSmith WAD DO and escaped redirect characters Support 6
W TCMD 16: double characters Support 11
MickeyF how to work with env var with special characters in the name Support 5
vefatica Fixed TPIPE doesn't /SPLIT at characters Support 0
A Escape characters on right side of pipe Support 0
J How to? 'tab' characters in the console and clipboard 'copy' Support 1
M How to? Determine a whether vars beginning with certain characters exist... Support 5
M Another simple question re. Take Command/TCC window witdth in characters... Support 16
U Keystack mangles 'special' characters Support 6

Similar threads