Page 2 of 2

Re: Output text without linefeed, even with leading space or =

Posted: 11 Jul 2021 09:24
by dbenham
:shock: SWEET :!: :D

Re: Output text without linefeed, even with leading space or =

Posted: 18 Nov 2021 10:16
by atfon
I love the "%comspec%" /d /k <nul solution here. However, I have a situation using this technique that I haven't been able to solve. Let's say I have a very simple menu like this:

Code: Select all

@echo off
setlocal enabledelayedexpansion
for /f %%g in ('%__APPDIR__%forfiles.exe /p "%~dp0." /m "%~nx0" /c "cmd /c echo 0x07"') do set "bel=%%g"
for /F "delims=#" %%e in ('"prompt #$E# & for %%e in (1) do rem"') do set "ESC=%%e"
:top
cls
echo(
echo    Main Menu
echo(
echo    1...............................................Refresh
echo    2...............................................Quit
echo(
set "prompt=   SELECT FROM THE MENU ABOVE AND PRESS [Enter]:"
"%comspec%" /d /k <nul
set /p "INPUT="
IF '%INPUT%'=='1' GOTO refresh
IF '%INPUT%'=='2' GOTO quit
:refresh
goto top
:quit
exit /b
Now, suppose I want to use a terminal escape sequence to display a title rather than using just the title command (so that it appears the same when run as Administrator or not):

Code: Select all

echo %ESC%]0;Main Menu%BEL%
Where can I use this terminal escape sequence in this scenario?

Edit:
To clarify somewhat further, if I put the terminal escape sequence for the title and run as Administrator, the title will appear as "Main Menu" until it hits the %comspec% line, when it changes to "Administrator: Main Menu." I'm trying to avoid that change.

Edit 2: I can sort of get it to work if I use this:

Code: Select all

"%comspec%" /d /k <nul & echo %ESC%]0;Main Menu%BEL%
However, that introduces the issue of a carriage return to the next line. Any suggestions?

Re: Output text without linefeed, even with leading space or =

Posted: 19 Nov 2021 02:07
by jeb
Hi atfon,
escape sequences can be outputted with the `set /p` technique.

Code: Select all

"%comspec%" /d /k <nul & <nul set /p ".=%ESC%]0;Main Menu%BEL%"

Re: Output text without linefeed, even with leading space or =

Posted: 19 Nov 2021 06:56
by atfon
jeb wrote:
19 Nov 2021 02:07
Hi atfon,
escape sequences can be outputted with the `set /p` technique.

Code: Select all

"%comspec%" /d /k <nul & <nul set /p ".=%ESC%]0;Main Menu%BEL%"
Thanks Jeb! I tried a bit with set /p, but didn't think to use the ".= for this. Worked like a charm. :)