Timer issue

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I was testing Vince's timing issue with arrays and noticed an odd issue with the TIMER command.
Code:
setarray /f a[100]
timer do i=0 to 99 (set a[%i]=0)
TCC: Invalid array argument (out of bounds) "a[100]"
...
TCC: Invalid array argument (out of bounds) "a[100]"
Timer 1 off: 14:51:15  Elapsed: 0:00:00.055

I had to double the %'s - set a[%%i]=0 - in order to get rid of the TCC error.

If I change the command to be timer & do ... & timer off then it works as I expected it to.

Why do I need to double the %'s ?

-Scott
 
May 20, 2008
11,400
99
Syracuse, NY, USA
I don't know the details, but that version of TIMER doesn't get parsed like many other things. Here's another.

Code:
v:\> (echo foo & echo bar)
foo
bar

v:\> timer (echo foo & echo bar)
Timer 1 on: 15:07:26
More?

Fix that one thus:

Code:
v:\> timer (echo foo ^& echo bar)
Timer 1 on: 15:08:15
foo
bar
Timer 1 off: 15:08:15  Elapsed: 0:00:00.002
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
I was testing Vince's timing issue with arrays and noticed an odd issue with the TIMER command.
Code:
setarray /f a[100]
timer do i=0 to 99 (set a[%i]=0)
TCC: Invalid array argument (out of bounds) "a[100]"
...
TCC: Invalid array argument (out of bounds) "a[100]"
Timer 1 off: 14:51:15  Elapsed: 0:00:00.055

I had to double the %'s - set a[%%i]=0 - in order to get rid of the TCC error.

If I change the command to be timer & do ... & timer off then it works as I expected it to.

Why do I need to double the %'s ?

-Scott

Because the command line is being parsed twice - once for TIMER, and then again for the DO.

The TIMER argument is intended for simple commands; it's not well suited for handling loops or command groups.
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
I don't know the details, but that version of TIMER doesn't get parsed like many other things. Here's another.

Code:
v:\> (echo foo & echo bar)
foo
bar

v:\> timer (echo foo & echo bar)
Timer 1 on: 15:07:26
More?

Fix that one thus:

Code:
v:\> timer (echo foo ^& echo bar)
Timer 1 on: 15:08:15
foo
bar
Timer 1 off: 15:08:15  Elapsed: 0:00:00.002

That would require a custom parser for TIMER on the (remote) chance that you're passing it a command group. Otherwise, when the parser is evaluating the TIMER line, it will break the line at the first &.

I don't think you'd be happy if the parser suddenly decided to evaluate possible command groups inside everything:

echo This is a line (and this isn't a command group)
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly PAUSE does not erase countdown timer Support 0
vefatica @TIMER's format ... Support 2
vefatica TIMER causes confusion Support 2
vefatica @TIMER's second parameter? Support 3
vefatica TIMER off by factor of 10 (or even 100) Support 4
J TCC 25 @TIMER regession Support 4
jbanaszczyk %@Timer Support 1
vefatica TIMER command Support 9
vefatica TIMER command Support 2
D TIMER OFF doesn't work Support 21
B Two Issues With TIMER Command In V14 Support 10
H TIMER bug Support 4
gunkelkarl timer ? Support 3
G v28 Display Issue Support 7
Jay Sage Issue with CD_ENTER Alias Support 37
Jay Sage Issue with CD_LEAVE Alias Support 3
fpefpe How to? issue with % and evaluation Support 5
cgunhouse Standard User Account Issue Support 2
samintz WAD Display wrapping issue Support 5
M TCC color issue in ConEmu Support 4
Alpengreis Documentation Minor issue in help file for view /E Support 1
samintz WAD ANSI issue Support 3
D TCSTART issue after reinstallation Support 14
A Documentation [Help file] OPTION "//" synopsis formatting issue Support 0
Chen Touboul Overtyping issue - i press the Insert key, help till press enter for new line in TCC Support 2
Y TCC and Cmder imcompatibility issue Support 7
M Another possibly strange remote registry issue Support 5
T WAD bpokestr issue Support 5
D High-DPI Scaling issue Support 1
S CMDebug 22 issue with del command Support 1
cgunhouse Foldermonitor Issue Support 7
samintz Build 38 Install issue Support 5
rps WAD Setlocal issue Support 4
Luiz Rodrigues Issue with Maven Support 1
Seven Update / install issue with 20.0.20.10.32 take command Support 7
Fross WebDav Drive Mapping Issue Support 19
D Upgrade issue Support 3
Fross V20b8 Everything Issue Support 5
T TCC display issue Support 1
cgunhouse _logfile Issue Support 5
T Fixed Querybox issue Support 1
cgunhouse Fixed Share Memory Issue Support 5
cgunhouse Foldermonitor with "/E" Option Issue Support 6
Fross TabComplete Argument Issue Support 1
fpefpe How to? Stange start up issue Support 1
C cosmetic issue with LIST's (I) Support 9
jbarnes1967 TC 18.00 x64 issue with lua io.popen() Support 2
D How to? Wildcards as sets - looping issue with FOR and REN Support 7
T WAD Free issue Support 6
R Fixed v17.0.54 Tab->COMSPEC Dialog Box Issue Support 2

Similar threads