TIMER OFF doesn't work

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
May 26, 2008
481
3
#1
TIMER OFF behaves just like TIMER. TIMER ON works as expected.

I reproduced this on two machines, two different recent builds:

TCC 14.03.54 x64 Windows 7 [Version 6.1.7601]
TCC 14.03.53 x64 Windows 7 [Version 6.1.7601]
 
May 20, 2008
420
2
#2
If the timer is already off, timer off will start a timer instead of reporting an error.

D:\>timer on
Timer 1 on: 9:39:04

D:\>timer off
Timer 1 off: 9:39:06 Elapsed: 0:00:01.22

D:\>timer off
Timer 1 on: 9:39:07

TCC 14.03.54 Windows 7 [Version 6.1.7601]
TCC Build 54 Windows 7 Build 7601 Service Pack 1
Tim
 
May 26, 2008
481
3
#3
Yes, that is the behavior I see. Is this actually by design? The help file for TIMER doesn't seem to indicate this behavior for the OFF option.

I want the ability to ensure the timer is off.
 
May 20, 2008
420
2
#4
The documentation indicates the (our) expected behavior.

OFF Force the stopwatch to stop

The documentation does not mention OFF as a start option. There is either a defect in behavior or in documentation. My guess is on behavior, but we need to wait for Rex on that.

Tim
 
#5
Verified: TCC 14.03.54 Windows XP [Version 5.1.2600]

I also noted that TIMER /S start the timer if it was not running already.

I further noted that REDIRECTING standard output from the TIMER command works only when the command STOPS the timer. For any other mode the command output goes to the screen, even when redirecting both standard output AND standard error.

Lastly, I think the documentation should display the command syntax thus:
TIMER [/1 | /2 | /3] [/Q] [/S | ON [command] | OFF | [command] ]
This applies both to the quick help and the help page, and is intended to indicate that
1/ options /1, /2 and /3 are mutually exclusive, but independent from the other groups
2/ option /Q is independent of all other options (but it makes no sense when combined with the /S option)
3/ options /S, ON and OFF are logically mutually exclusive (though /S combined with ON or OFF may not be reported as errors, but the effect of combining two or all three do not result in a dependable operation); specifying command to be timed is valid only when the ON option is used either explicitly or implicitly, but not when either the /S or the OFF option is used.

My current tests indicate that executing TIMER OFF /S when timer 1 is already off starts it; executing it when it is running the OFF is ignored, regardless of the order of the options. Combining all three options /S, ON and OFF the outcome depends on the order of the options and the current state of the timer. I did not go through all 24 combinations of multiple option selection, option order, and previous timer state. IMHO it would be best if the parser would declare any combination of these options to be error.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#6
The documentation indicates the (our) expected behavior.

OFF Force the stopwatch to stop

The documentation does not mention OFF as a start option. There is either a defect in behavior or in documentation. My guess is on behavior, but we need to wait for Rex on that.
WAD -- this was changed when the ability to time commands was added. There was a discussion at the time & the general consensus was that since there wasn't any reason to do a "timer off" when you weren't running a timer, it didn't impose much of a burden.
 
#7
WAD -- this was changed when the ability to time commands was added. There was a discussion at the time & the general consensus was that since there wasn't any reason to do a "timer off" when you weren't running a timer, it didn't impose much of a burden.
Why was it changed ... in case you wanted to time OFF.EXE or OFF.BTM? It *is* an inconvenience to say I want the timer off only to have it started!
 
#9
Why do you want want to turn the timer off if it's already off??
What I don't know if it's on or off. That has often been the case when I'm trying to time something to make a point here in the forums and it takes a few tries to get my command error-free. The point is there's no way to force it to be off. The only old thread I could find on the subject was rather one-sided. You said "this is how it is now" and others offered alternatives like "timer ... /cmd <command>" and "timer ... (<command>)" (as with DO).
 
#11
What I don't know if it's on or off... The point is there's no way to force it to be off.
As it works today in 14.03.54, the 2-command sequence "TIMER /S %+ TIMER" will turn it off. The first command is "do nothing" if it is already on, but it starts it if it was off; the second command will turn it off. It is certainly not as nice as the original design - "OFF" meat OFF!
 
#12
The current mode of operation violates POLA.
The Principle of Least Astonishment (POLA) states that the result of performing some operation should be obvious, consistent, and predictable, based upon the name of the operation and other clues.
 
#13
What if I don't know the current state, but know that I want it off? Or put another way, why should the current state matter? If the instruction is to turn it off, why not just turn it off consistently regardless of the current state? Is this intended to be a toggle?
That's my opinion, too.
I stumbled over this behavior a while ago and it drives me crazy that "off" turns the timer "on".
 
May 26, 2008
481
3
#14
Why do you want want to turn the timer off if it's already off??
In my case I was running a batch file that did various "timer & command & timer" things. I was troubleshooting something and would break out (CTRL+C) of the batch file and re-run it. This was causing issues with the timer if I broke out while "command" was running. I tried putting "timer off" at the beginning and I was surprised that "timer off" will turn it back on if it was off.
 
May 20, 2008
420
2
#16
The current documentation states that off is off, not on. That is inaccurate with the current implementation. If this is WAD, perhaps the documentation should be amended for OFF. To force a timer off, first force it on, then force it off.

Tim
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#17
There seems to be a general misconception that when a timer is active, there's something running in the background that has to be turned "off" before anything else can be done. This is not true -- a "timer on" (or just "timer" if no timer is active) simply saves the current time. The next "timer" (or "timer off") gets the current time, subtracts the saved time, displays the result, and clears the flag indicating that a timer is active.

A "timer off" is never necessary to reset a timer -- just do another "timer on" and the old saved time is replaced by the new time.

Or, just do a "timer command" and you don't have to worry about "timer on" or "timer off".

This thread conforms to the POLS (Principle of Least Significance) -- the less significant the issue, the more passionate the arguments. :dead:
 
#18
I can't believe this has gone on so long. It's just ridiculous that "TIMER OFF" turns the timer on. Many have agree, none have disagreed. In v13, "TIMER OFF" leaves a timer that's off off (just as any reasonable person would expect).
 
May 20, 2008
420
2
#19
The details behind the implementation are irrelevant. Its about expected behavior. It is not a misconception that with every other iteration of consecutive 'timer off' commands, the documentation is wrong about the expected behavior.

Tim
 
May 26, 2008
481
3
#20
I can't believe this has gone on so long. It's just ridiculous that "TIMER OFF" turns the timer on. Many have agree, none have disagreed. In v13, "TIMER OFF" leaves a timer that's off off (just as any reasonable person would expect).
Exactly..... TIMER OFF should never turn it back on! Just as TIMER ON should never turn it off!
 
#22
Perhaps Rex should wipe out the "Off" option. From program and documentation.