placing text on screen

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ragster66
Posts: 3
Joined: 05 Jan 2018 13:24

placing text on screen

#1 Post by ragster66 » 23 Jan 2018 18:40

Hi there.. If I type the following
pause
it displays
Press any key to continue
it shows this along the left edge of the screen.... How do get it to display say in mid screen.?

Similarly for this
set /p input=Choice:
the word choice: is on left of screen, how do I get it in mid screen?
Thanks

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: placing text on screen

#2 Post by Squashman » 23 Jan 2018 19:23

The SET /P command consumes all white space at the beginning of the prompt string. So you have to trick it.

Code: Select all

@echo off

:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"

set /p "input=x%BS%                   Choice:"
echo %input%
pause

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: placing text on screen

#3 Post by Squashman » 23 Jan 2018 19:29

And now we can use a little more trickery to get your desired result for the pause command.

Code: Select all

@echo off
:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"

set /p ".=x%BS%                       x%BS%"<nul&pause
echo.
echo. After Pause
pause

Post Reply