how can I store a paragraph in a variable

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

how can I store a paragraph in a variable

#1 Post by Adrianvdh » 12 Jun 2013 14:11

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 :)

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: how can I store a paragraph in a variable

#2 Post by Endoro » 12 Jun 2013 15:33

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!

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: how can I store a paragraph in a variable

#3 Post by Adrianvdh » 13 Jun 2013 07:38

Thanks a lot for you help :) but is there any way to remove the ' " ' from the lines?

Thank you for all your time :)

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: how can I store a paragraph in a variable

#4 Post by foxidrive » 13 Jun 2013 07:53

But your example lines are double quoted. :D

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.

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: how can I store a paragraph in a variable

#5 Post by Endoro » 13 Jun 2013 08:04

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!

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: how can I store a paragraph in a variable

#6 Post by Adrianvdh » 13 Jun 2013 09:36

Hello...
Um, sorry about that? How do I remove the ' quotes ' from each line

Thanks you for all your help :)

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: how can I store a paragraph in a variable

#7 Post by foxidrive » 13 Jun 2013 09:39

It's done. See above.

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: how can I store a paragraph in a variable

#8 Post by Adrianvdh » 14 Jun 2013 06:34

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

Post Reply