%_selected no longer working

Jun 2, 2008
284
1
Newton, MA
#1
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.

upload_2015-12-28_14-43-40.png

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

upload_2015-12-28_14-44-13.png
 
Jun 2, 2008
284
1
Newton, MA
#2
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

upload_2015-12-28_15-3-35.png

I click on the EREN button and get the following:

upload_2015-12-28_15-4-15.png

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

upload_2015-12-28_15-7-51.png
 
#3
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.
Code:
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.
Code:
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[]
ECHO is OFF

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

Attachments

Jun 2, 2008
284
1
Newton, MA
#4
Vince,

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.
 
#5
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?
 
#6
I've whittled down the BTM even further.
Code:
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" ^
   /head=0,0,24]
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.
Code:
v:\> 123.btm
0

v:\> echo %@quote[]
ECHO is OFF

v:\> echo %@quote[v:\> 123.btm]
"v:\> 123.btm"
 

rconn

Administrator
Staff member
May 14, 2008
10,755
97
#8
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​
Not reproducible here -- I tried it a couple dozen times & it always worked.
 
#9
Here's a very simple one that shows a problem here. Make a button ("test") that sends this to the current tab:
Code:
esc "echo %%@quote[%_selected]" enter
Execute this command:
Code:
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:
Code:
v:\> echo abc def | tpipe /grep=3,0,0,1,0,0,0,0,"ab"
abc def

v:\> echo %@quote[]
ECHO is OFF

v:\> echo %@quote[abc def]
"abc def"
 
Last edited:
#11
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,755
97
#13
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.
 
#14
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.
 
#15
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.
 
#16
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.