• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1614
  • Last Modified:

Blat question: Does anyone know how to insert carriage return/line feeds in a test string.

I have these variables set in a batch file:

Set BodyLine1="...."
Set BodyLine2="...." etc.
...up to 5.

At some point in the script I issue the command:

Blat -body "%BodyLine1%%BodyLine2%%BodyLine3%...", which works, but strings the text lines together, as expected.  Can I store a CRLF character in a variable and insert it between the lines in the string?  If so, how?

Thank you.
0
Randy_R
Asked:
Randy_R
  • 3
  • 2
  • 2
  • +2
1 Solution
 
HRLCommented:
concatenate the string as follows:
%STring1% + Char(13) + Char(10) + %String2% + ....
0
 
Randy_RAuthor Commented:
What I get back is this:

1 + Char(13) + Char(10) + 2 + Char(13) + char(10) + 3 + CHar(13)+Char(10) + 4 + Char(13) + Char(10) + 5

my variables are expanded properly but not the CR/LF.  I tried enclosing the entire string in quotes but it didn't help.
0
 
mish33Commented:
Try embed newlines into the strings like

Set BodyLine1="....\r\n"
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Randy_RAuthor Commented:
Nope.  Just takes them as additional string characters.
0
 
Bill PrewCommented:
I think what you need to do is write your body lines to a text file first, and then on the blat command line pass in the name of that file, rather than the -body option.  So something like:

echo Sample Line 1>body.txt
echo Sample Line 2>>body.txt
echo Sample Line 3>>body.txt

blat "body.txt" -to ...

~bp
0
 
Randy_RAuthor Commented:
That did it bp!  Thanks!
0
 
Bill PrewCommented:
Great, glad that was helpful, thanks.

~bp
0
 
knightEknightCommented:
You can use string substitution and a little known trick to achieve this.  For example, let's say you want to use \n to represent your new line characters:


set nltest=This is\na new\nline test.
echo %nltest:\n=&echo.%
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now