Welcome!

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

SignUp Now!

Just an out-of-curiosity question re. "Do ... /P ..."

NO, No, No. The entire rest of your batch file is in the DO loop. But you didn't end it with ENDDO so it falls right out of the batch file.

There are two forms of DO.

1. DO ... (command)

2. DO ...
command
command
...
ENDDO

Yours is of the second kind and the batch file ends before any corresponding ENDDO is found. Don't believe me ... put an ENDDO where you think the DO is over and you won't see StartTime and EndTime (and there would be an error message if you weren't in a DO loop).

Code:
@Echo Off
::SetLocal
Do StartTime In /P Timer on /2()
EndDo
Set I=
Do While %I LT 10000
  Set /A I+=1
EndDo
Do EndTime In /P Timer off /2()
EndDo
@Echo Start Time: %@Word[3,%StartTime]
@Echo  End Time: %@Word[3,%EndTime]  Elapsed Time: %@Word[5,%EndTime]
::EndLocal
Quit 0
 
v:\> dotest.btm
Start Time:
 End Time:   Elapsed Time:
 
Vince, thank you! And I'm laughing as I type this! :D Somehow I had gotten the impression that some "kinds" of DO used open and close parenthesis, and other kinds used the "EndDo". I had no clue as to why that was the case; and it frankly irritated the heck out me because I really hated that syntax! And given that that is the case, you are correct in all respects! I'm not going to bother to change existing batch files that work (it still is for the most part really academic) unless and until I need to modify them for other reasons; but I will start doing what you suggest for new ones since it's really not all that difficult. - Dan
 

Similar threads

Back
Top