Tuesday, September 12, 2006

Pause Replacement

Here it is a "pause" command replacement which waits for ENTER instead of any key. It uses SET /P:
SET /P =Press Enter to continue . . .
This trick uses the set feature "prompt for value" (/p) which will wait for a user given value, which is confirmed by pressing ENTER. However we don't specify a variable so we only wait for ENTER. Any other characters are printed on screen in the wait for ENTER.
However, we can also read the value in a variable like:
SET /P a=What is the value of a? a=
At the end the variable a will have the user-given value.

No comments: