Page 1 of 1

can you set multiple lines into one variable?

Posted: 02 Oct 2011 12:21
by BatMaster
hey guys
i was just wondering if its possible to set multiple lines into one variable
if it is please tell me if not tell me anyway

Re: can you set multiple lines into one variable?

Posted: 02 Oct 2011 16:08
by aGerman
It's possible and you will find a few examples in this forum.

Code: Select all

@echo off
:: Create LineFeed character ::::::::::::::
set lf=^


:: Two empty lines above are neccessary! ::

set "line1=Hello"
set "line2=World!"

setlocal enabledelayedexpansion
:: merge both variables
set "var=!line1!!lf!!line2!"
:: display the result
echo !var!
endlocal

pause

Regards
aGerman

Re: can you set multiple lines into one variable?

Posted: 03 Oct 2011 10:37
by BatMaster
Thanks alot that realy helps
-=BatMaster=-
:D :D :D :D :mrgreen:

Re: can you set multiple lines into one variable?

Posted: 08 Oct 2011 01:27
by Rileyh
aGerman,
What are the "!!" for?

Rileyh

Re: can you set multiple lines into one variable?

Posted: 08 Oct 2011 08:57
by aGerman
The ! replaces the % for environment variables if enabledelaiedexpansion was set and you have to expand this variable more than once in a command line or a block.

Regards
aGerman