DosTips.com

A Forum all about DOS Batch
It is currently 30 Sep 2016 09:07

All times are UTC-06:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 01 Jan 2012 17:52 
Offline

Joined: 24 Apr 2011 19:20
Posts: 82
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?


Top
   
PostPosted: 01 Jan 2012 18:47 
Online
Expert

Joined: 22 Jan 2010 18:01
Posts: 2326
Location: Germany
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


Top
   
PostPosted: 01 Jan 2012 21:26 
Offline

Joined: 24 Apr 2011 19:20
Posts: 82
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?


Top
   
PostPosted: 03 Jan 2012 20:38 
Offline
Expert

Joined: 06 Dec 2011 22:15
Posts: 1191
Location: México City, México
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.


Top
   
PostPosted: 17 Mar 2012 10:03 
Offline

Joined: 17 Mar 2012 09:59
Posts: 60
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


Top
   
PostPosted: 17 Mar 2012 11:22 
Offline
Expert

Joined: 12 Feb 2011 21:02
Posts: 1719
Location: United States (east coast)
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Yahoo [Bot] and 9 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® Forum Software © phpBB Limited