Page 1 of 1
how can I store a paragraph in a variable
Posted: 12 Jun 2013 14:11
by Adrianvdh
Hello everyone...
Could someone please tell me

how I can store a paragraph, or sentence lines e.g...
"I like the colour blue"
"I like pets"
"My favourite pet is a boxer dog"
Yes like that rather

, How could I do that. With spaces, ect

just in one variable.
So if I...
echo "%var%"
it would echo the lines, or something close to that, what every you can do will be great!
Thank you for your time, and helping everyone on the forum

Re: how can I store a paragraph in a variable
Posted: 12 Jun 2013 15:33
by Endoro
try this:
Code: Select all
@echo off &setlocal enabledelayedexpansion
set "myparagraph="I like the colour blue""I like pets""My favourite pet is a boxer dog""
set LF=^
REM ^two empty lines are important^
set "myparagraph=%myparagraph:""="!LF!"%"
echo !myparagraph!
Re: how can I store a paragraph in a variable
Posted: 13 Jun 2013 07:38
by Adrianvdh
Thanks a lot for you help

but is there any way to remove the ' " ' from the lines?
Thank you for all your time

Re: how can I store a paragraph in a variable
Posted: 13 Jun 2013 07:53
by foxidrive
But your example lines are double quoted.

Think a bit more carefully about your question... and explain why you need to do it.
There are a mountain of tricks and techniques that could work, if the actual task is described.
Re: how can I store a paragraph in a variable
Posted: 13 Jun 2013 08:04
by Endoro
Thank you @foxidrive

and here the code:
Code: Select all
@echo off &setlocal enabledelayedexpansion
set "myparagraph=I like the colour blue""I like pets""My favourite pet is a boxer dog"
set LF=^
REM ^two empty lines are important^
set "myparagraph=%myparagraph:""=!LF!%"
echo !myparagraph!
Re: how can I store a paragraph in a variable
Posted: 13 Jun 2013 09:36
by Adrianvdh
Hello...
Um, sorry about that? How do I remove the ' quotes ' from each line
Thanks you for all your help

Re: how can I store a paragraph in a variable
Posted: 13 Jun 2013 09:39
by foxidrive
It's done. See above.
Re: how can I store a paragraph in a variable
Posted: 14 Jun 2013 06:34
by Adrianvdh
Oh sorry

I did not realise, thank you guys so much for the code. And thank you for all your time aswell