@HISTORY issues

Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  26.01.40 x64   Windows 10 [Version 10.0.18362.778]

I want to obtain a single line from the history list.

I am using local history.

Code:
e:\utils>history /m | tail
182 : history
183 : history >> history.txt
184 : history /m
185 : help type
186 : tail | history /m
187 : echo %@history[185]
188 : history /m | *view
189 : npp test.btm
190 : history /m | tail
191 : subnet.btm

If I try to get line 185;
Code:
e:\utils>echo %@history[185]
cdd C:\Users\JOECAV~1\AppData\Local\Temp
...that line does not even exist in the history list.

If I try to get line 189;
Code:
e:\utils>echo %@history[189]
alias cd*
...that is actually line 3 in the history file.

If I try to get the current line;
Code:
e:\utils>echo %@history[0]
...the TCC session hangs.

If I try to get the current line and a specific word;
Code:
e:\utils>echo %@history[189,0]
189

e:\utils>echo %@history[189,1]
1

Not sure what I'm doing incorrectly, but assistance would be appreciated.

Joe
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,496
91
Albuquerque, NM
prospero.unm.edu
For one thing, note that HISTORY /M numbers lines in the opposite order from @HISTORY. HISTORY /M calls the oldest line #0. I think HISTORY /M /V would make more sense here.

As for @HISTORY[0], I think this leads to infinite recursion: To expand @HISTORY[0], you must first expand @HISTORY[0]....
 
Okay, I used history /m /v...
Code:
e:\utils>history /m /v | tail
 194 : which ram
 195 : help switch
 196 : c2p cd_enter.*
 197 : cdd %temp%
 198 : dir *.log
 199 : help trace
 200 : alias cd*
 201 : dir cd_enter.btm
 202 : alias CD_Enter=e:\utils\cd_enter.btm
 203 : rnt da

e:\utils>echo %@history[198]
dir *.log

e:\utils>echo %@history[198]
dir *.log

e:\utils>echo %@history[199]
dir *.log

e:\utils>echo %@history[198]
cdd C:\Users\JOECAV~1\AppData\Local\Temp

Note that the first and second tries are correct, but the third (199) returns the same as (198). The fourth, again, (198), returns an incorrect line, and it does not even exist in history.

The help says that if I set x to 0, it will retrieve the current line, but it just hangs TCC, which you think is infinite recursion.

Joe
 

rps

Jul 6, 2008
436
6
Okay, I used history /m /v...
Code:
e:\utils>history /m /v | tail
194 : which ram
195 : help switch
196 : c2p cd_enter.*
197 : cdd %temp%
198 : dir *.log
199 : help trace
200 : alias cd*
201 : dir cd_enter.btm
202 : alias CD_Enter=e:\utils\cd_enter.btm
203 : rnt da

e:\utils>echo %@history[198]
dir *.log

e:\utils>echo %@history[198]
dir *.log

e:\utils>echo %@history[199]
dir *.log

e:\utils>echo %@history[198]
cdd C:\Users\JOECAV~1\AppData\Local\Temp

Note that the first and second tries are correct, but the third (199) returns the same as (198). The fourth, again, (198), returns an incorrect line, and it does not even exist in history.

The help says that if I set x to 0, it will retrieve the current line, but it just hangs TCC, which you think is infinite recursion.

Joe
Every time you issue a command (echo %@history...) the history list grows moving existing history items.
Perhaps you should try @echo %@history[199] .... since this will not add to the history stack, thus leaving your original displayed items in the same positions.
Code:
197 : d cddexecTest.btm
 198 : cddexecTest.btm
 199 : CDD-test.btm
 200 : CaseTest.btm
v26.01.40_$@echo %@history[198]
cddexecTest.btm
v26.01.40_$@echo %@history[199]
CDD-test.btm
v26.01.40_$@echo %@history[198]
cddexecTest.btm
The fourth seems correct if %temp%=C:\Users\JOECAV~1\AppData\Local\Temp since the %temp% variable would be expanded on the command line displayed. (cdd %temp%) :smile:
 

rconn

Administrator
Staff member
May 14, 2008
12,406
152
This can be a little confusing, because it is going to depend on things like whether you're allowing or removing duplicate history entries. If you don't prefix each ECHO with an @, it *may* (depending on your dup setting) add another line to the history, shifting everything. And if you run out of history space, things are going to get even more confused when TCC deletes the old entries and shifts everything around. Let's not even talk about what happens when TCC eliminates old dups and adds the new entry at the end.

And if you have history wrapping on, and you enter a value > than the number of entries, you'll get a wrapped result.
 
Similar threads
Thread starter Title Forum Replies Date
J History file load hangs if file has complete garbage in it... Support 1
R History window wrong size, can't remember size change Support 12
T How to? retain command history across reboot? Support 6
nikbackm Speeding up the history dialog Support 6
D ParentDirectory does not update directory history Support 6
vefatica Command history search is off Support 7
D Directory History Window with wildcard search Support 3
R Long commands retrieved from command history have blank line when wrapped Support 20
vefatica Deleting entries in the command history popup? Support 3
H History and TPipe Oddness Support 3
D History and control-C Support 1
G Console exe up / down history Support 8
D What does the file "..\Everything\Run history.csv" store? Support 5
rps Cmd history recall Support 4
David McClelland Command history loosing entries Support 18
R history features. Support 6
rps How to? Shralias and producing history.sav, alias.sav .. Support 6
M Ctrl-C when using command line history does nothing Support 2
S Debugger Bat file call history Support 9
Charles Dye Ctrl-Shift-Up doesn't update directory history Support 1
vefatica ESC after recalling a command from history Support 3
T TCHelp executable history? Support 2
thorntonpg @blahblah added to history. Support 0
M Call History popup-window? Support 0
M HISTORY lessons ... Support 0
vefatica The help and IE's history Support 16
D Towards shared (dir-)history lists Support 3
vefatica Ctrl-Enter in command history window? Support 8
vefatica History recall turns off Quick-Edit Support 4
C history is getting deleted under unknown circumstances Support 9
R V19 - At startup, TCC save directory in the directory history list Support 2
T [TCC 18] Can't read nor write history Support 1
I Possible Bug: History /n Returns Nothing Support 3
jbanaszczyk Lost history Support 4
T history.sav Support 4
T How to? sort history in tcexit.btm Support 22
vefatica OT: Windows console history? Support 7
S directory history locks up TCC Support 3
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
E TCC History popups too small Support 0
C How to? Keeping all history lists Support 4
E Command History not showing on up arrow button Support 8
nikbackm HISTORY /R1 performance Support 3
T Selecting line from popup history without executing Support 8
A How to? Filter history list with unicode chars Support 0
vefatica WAD HISTORY /R, No closing quote? Support 10
vefatica WAD DO /S ... all dirs wind up in the history! Support 12
D Dir History file check Support 18
ehab aboudaya How to? Command Input history for each tab? Support 0
A Ctrl-1 and the command history Support 5

Similar threads