在批处理文件中合并两个调用命令

时间:2018-12-13 23:05:48

标签: batch-processing

好的,我正在编写一个BATCH文件来更改文本和/或背景的颜色。这是我到目前为止的内容:

@echo off

:: Sets the size of the command window

mode con: cols=62 lines=40

:: Sets the TITLE of the command window

::ACTUAL PROGRAM STARTS HERE

title=Text Color Chart for BATCH

SETLOCAL DisableDelayedExpansion

for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1)
do rem"') do (

  set "DEL=%%a"
)

call :ColorText 0a "  0a prints in Green"

call :ColorText 0b "  0b prints in Auqa"

call :ColorText 0c "  0c prints in Red"

call :ColorText 0d "  0d prints in Purple"

call :ColorText 0e "  0e prints in Yellow"

call :ColorText 0f "  0f prints in white"

echo.
pause
goto :eof
:: since :eof does not exist, the program ends here!


:: ============= SUBROUTINES START HERE ======================

:ColorText

echo off

<nul set /p .=. > "%~2"

findstr /v /a:%1 /R "^$" "%~2" nul

echo(%DEL%%DEL%%DEL%

del "%~2" > nul 2>&1

exit /b

:: ============== SUBROUTINES STOP HERE ======================

现在我的问题是,有没有办法结合两个“ CALLS”在同一行上回显?
示例:调用:ColorText 01“ Hello” +调用:ColorText 0c“ World!”

所以打印输出将是(绿色)你好(空格)(红色)世界!

在此先感谢您提供的任何帮助!

0 个答案:

没有答案