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

SignUp Now!

%_selected no longer working

I have a number of buttons that rely on %_selected to pass along the text that is selected in the TCMD window. It is no longer working.


After selecting "echo" and pressing the Enter key, I get this:

The test above does not work in TCMD17 either, so it is apparently not a proper test. Here is the real problem.

I have a toolbar button called EREN with the following command specification:

esc "eren %%@quote[%_selected]" enter​

With the screen looking like this


I click on the EREN button and get the following:


In TCMD17, the button works fine and I get the following:

It somehow has something to do with what was recently done. This is strange!

I have a button, "test", which sends the following to the current tab.
esc "echo %%@quote[%_selected]" enter
The attached batch file should work for anyone, and produce a list of the temperatures in Syracuse, NY for each of the last 24 hours plus the average. There's nothing peculiar in it. Run it, then select one line of its output, the button will fail as Jay described. After that the button will work as expected. Run the BTM again and the button will fail (again only once).
Here's the result of running the BTM, selecting its last output line and pressing the button ... then selecting the same line and pressing the button again.
v:\> 123.btm
15:54  28
14:54  28
13:54  27
12:54  26
11:54  26
10:54  26
09:54  25
08:54  24
07:54  24
06:54  27
05:54  30
04:54  30
03:54  32
02:54  33
01:54  32
00:54  33
23:54  33
22:54  33
21:54  33
20:54  34
19:54  35
18:54  35
17:54  35
16:54  35

Average: 30.17

v:\> echo %@quote[]

v:\> echo %@quote[Average: 30.17]
"Average: 30.17"


  • 123.btm
    477 bytes · Views: 232

I'm glad you were able to reproduce the problem. I was beginning to think I was losing my mind.

I just installed TCMD19 on another computer, and it was working fine there. On my main computer, I could not get it to recover until I rebooted. Now %_selected is working again. I'll have to watch and try to determine what I did to make it stop.
I was using v19 all along. And the behavior is as I described with v17 and v18, but not with v16 (i.e., it worked correctly with v16). Jay, did you try to reproduce my experiment?
I've whittled down the BTM even further.
copy /q "http://w1.weather.gov/data/obhistory/KSYR.html" %TEMP\ksyr.tmp

setarray /F l[24]

echo %@execarray[l,tpipe /input=%TEMP\ksyr.tmp ^
   /grep=3,0,0,1,0,0,0,0,"right.*left" ^
   /replace=4,1,0,1,0,0,0,0,0,".*([0-9][0-9]:[0-9][0-9]).*td.(-*[0-9]*)..td..td.*[0-9]*..td.$","$1  $2" ^
The results are the same after running the BTM, and (twice) selecting the previous command line (v:\> 123.btm) and pressing my "test" toolbar button.
v:\> 123.btm

v:\> echo %@quote[]

v:\> echo %@quote[v:\> 123.btm]
"v:\> 123.btm"
And I have duplicated all I've said on my work machine (also Win7/32, TCMD v19 b27).
Here's a very simple one that shows a problem here. Make a button ("test") that sends this to the current tab:
esc "echo %%@quote[%_selected]" enter
Execute this command:
echo abc def | tpipe /grep=3,0,0,1,0,0,0,0,"ab"
Now select the just-echoed "abc def" and press the "test" button.
Select the same text again and press "test" again.
Here's what I see:
v:\> echo abc def | tpipe /grep=3,0,0,1,0,0,0,0,"ab"
abc def

v:\> echo %@quote[]

v:\> echo %@quote[abc def]
"abc def"
Last edited:
Vince's test reproduces as described for me:


In fact, I can do it more than once.
It may be a problem related to piping. The same thing happens with the command lines

echo abc def | type
echo abc def | view​

Now, when this first happened to me, %_selected stopped working permanently, and only a reboot restored proper operation. So I must have done something else. I don't think that I am using piping in my aliases or scripts, and I certainly did not do it manually.
It may be a problem related to piping.
Yes, indeed ... and only piping to internals. There's no problem piping to GREP.EXE or SORT.EXE, but the problem shows up with either of these:
echo abc def | ffind /t"ab"
echo abc def | do x in @CON: ( echo %x )
The %_selected expansion occurs inside TCMD, not TCC. TCMD is trying for a PID match on the console session, but the child pipe process breaks that when it does some IPC with TCMD and then disappears. If the parent TCC process then does some IPC, things get reset; otherwise TCMD doesn't know who's talking to it.

This is exactly the same behavior in every version of TCMD / TCC; the only difference will be in the timing of the IPC.

I might be able to work around it by forcing a dummy IPC after the child pipe process exits.
I'm back in the state where %_selected will not work at all, even after shutting down TCMD and starting it up again (even killing SHRALIAS, in case that had anything to do with it). I am unable to get things working except by rebooting the computer, which is a huge nuisance.

Unfortunately, I don't know what I did that may have precipitated the problem. Maybe I should turn on command logging so I can go back and look.
Well, I did turn on logging, and the problem did come back. I was logging only commands, not everything, but the variable returned a value in one command and failed in the next command. So it would appear that something I was doing outside of TCMD may have caused the problem to appear (though that seems to me hard to imagine). Now I'll try turning on logging of all activity (after rebooting) and see if something else was going on that did not get logged.
Ugh. I tried it once more before rebooting, and now it's working again! I wonder if perhaps the text that I had selected became unselected without my noticing.

I'm now having trouble with the LOG command. A new LOG command with different options is not superseding the previous command, and the log file does not contain the date stamp described in the help file. I'm going to reboot and start over.

Similar threads