Page 1 of 1

placing text on screen

Posted: 23 Jan 2018 18:40
by ragster66
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

Re: placing text on screen

Posted: 23 Jan 2018 19:23
by Squashman
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

Re: placing text on screen

Posted: 23 Jan 2018 19:29
by Squashman
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