How in my batch I can echo.
ONLY if the previous line outputted is non-empty ? As you understood I want to avoid to have 2 /n/n
Write a function for echo
, that remember if the last line was empty.
@echo off
call :func1
call :func2
:func1
call :echo "Func1"
call :echo ""
call :echo ""
exit /b
:func2
call :echo ""
call :echo "Func2"
exit /b
:echo
set "text=%~1"
setlocal EnableDelayedExpansion
if "!text!!last_line!" NEQ "" (
echo(!text!
)
endlocal
set "last_line=%~1"
exit /b
Output:
Func1
Func2