Sure: -)
And you can embed several named paragraphs in your script and selectively write them using a unique label for each.
Named text can be displayed anywhere in the script as long as GOTO and / or EXIT / B do not allow text to be executed.
The following is a script encapsulating logic in a procedure :printParagraph .
@echo off setlocal disableDelayedExpansion goto :start :::BeginText1 Paragraph 1 is preserved Bye! :::EndText :start echo Print paragraph 1 directly to screen echo ------------------------------------------ call :printParagraph 1 echo ------------------------------------------ echo( echo( call :printParagraph 2 >test.txt echo Write paragraph 2 to a file and type file echo ------------------------------------------ type test.txt echo ------------------------------------------ echo( echo( echo Print paragraph 3 directly to screen echo ------------------------------------------ call :printParagraph 3 echo ------------------------------------------ echo( echo( exit /b :::BeginText2 This is paragraph 2 Pure poetry :::EndText :printParagraph set "skip=" for /f "delims=:" %%N in ( 'findstr /x /n ":::BeginText%~1" "%~f0"' ) do if not defined skip set skip=%%N set "end=" for /f "delims=:" %%N in ( 'findstr /x /n ":::EndText" "%~f0"' ) do if %%N gtr %skip% if not defined end set end=%%N for /f "skip=%skip% tokens=*" %%A in ( 'findstr /n "^" "%~f0"' ) do ( for /f "delims=:" %%N in ("%%A") do if %%N geq %end% exit /b set "line=%%A" setlocal enableDelayedExpansion echo(!line:*:=! endlocal ) exit /b :::BeginText3 One more... ...for good measure :::EndText
source share