Welcome!

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

SignUp Now!

@HISTORY issues

Aug
1,929
71
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
 
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
 
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:
 
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

Back
Top