View unanswered posts | View active topics It is currently 01 Sep 2014 22:18



Post new topic Reply to topic  [ 6 posts ] 
Changing the PAUSE prompt 
Author Message

Joined: 24 Apr 2011 19:20
Posts: 82
Post Changing the PAUSE prompt
Hello,

This is sort of a dumb question, but is it possible to modify the PAUSE prompt witout creating a new line under the new prompt? I am aware of the
Code:
ECHO [message]
PAUSE > NUL
trick, but the blank line under the message annoys me. Is there any way to get rid of this blank new line?


01 Jan 2012 17:52
Profile
Expert

Joined: 22 Jan 2010 18:01
Posts: 1753
Location: Germany
Post Re: Changing the PAUSE prompt
It's possible even if it looks a bit odd
Code:
pause>nul|set /p "=[message]"<nul&echo(

The "echo(" let the cursor jump to the next line after you hit a key.

Regards
aGerman


01 Jan 2012 18:47
Profile

Joined: 24 Apr 2011 19:20
Posts: 82
Post Re: Changing the PAUSE prompt
aGerman wrote:
It's possible even if it looks a bit odd
Code:
pause>nul|set /p "=[message]"<nul&echo(

The "echo(" let the cursor jump to the next line after you hit a key.

Regards
aGerman
Works perfectly! Thanks! I figured I needed to include SET /P in there somewhere, but I wasn't sure how. I just have one question: what does the < character do? I know > and >> are used for redirection. Is < used for feedback or something?


01 Jan 2012 21:26
Profile
Expert

Joined: 06 Dec 2011 22:15
Posts: 718
Location: México City, México
Post Re: Changing the PAUSE prompt
Just change your ECHO by SET /P =[message]< NUL
Code:
SET /P =[message]< NUL
PAUSE > NUL

The < redirector indicate the command to take its input from the file instead the keyboard. NUL is the standard "empty" DOS file.


03 Jan 2012 20:38
Profile

Joined: 17 Mar 2012 09:59
Posts: 60
Post Re: Changing the PAUSE prompt
I'm so glad i found this forum/topic!

Even though i'm not looking for a solution on how to change the PAUSE prompt, i've been looking for a decent pause replacement for ages.
This to work around the problem where a second pause irritation would be skipped if any of the function- or arrow-keys were pressed:

http://stackoverflow.com/questions/6958272/arrow-keys-trigger-pause-twice-in-windows-batch-files

PAUSE>NUL|SET /P =[optional] did the trick for me.

Thank you aGerman, and thank you dostips.com!

Best regards,
©opy[it]®ight


17 Mar 2012 10:03
Profile
Expert

Joined: 12 Feb 2011 21:02
Posts: 1207
Location: United States (east coast)
Post Re: Changing the PAUSE prompt
That is an interesting simplification - the <nul is not required. Also the quotes are not needed unless the message contains special characters. But the &echo( should be preserved so that the cursor moves to the next line properly.

Code:
pause>nul|set/p=[message]&echo(

This seems a good candidate for a macro :!: :D

Code:
@echo off

:: Define a PAUSE macro that properly handles arrow and function key presses
:: and also allows a custom pause message
set pause=for %%n in (1 2) do if %%n==2 (for /f "eol= tokens=*" %%a in ("!args!") do (endlocal^&pause^>nul^|set/p=%%a^&echo()) else setlocal enableDelayedExpansion^&set args=

:: Demonstrate usage of the PAUSE macro
echo Part 1
%pause% Press any key to continue . . .
echo Part 2
%pause% Custom pause message . . .
echo Part 3


Dave Benham


17 Mar 2012 11:22
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: ShadowThief, Yahoo [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.