Solved

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

Posted on 2010-09-08
9
1,128 Views
Last Modified: 2012-06-28
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
Comment
Question by:Randy_R
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 4

Expert Comment

by:HRL
ID: 33627998
concatenate the string as follows:
%STring1% + Char(13) + Char(10) + %String2% + ....
0
 

Author Comment

by:Randy_R
ID: 33628136
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
 
LVL 15

Expert Comment

by:mish33
ID: 33628336
Try embed newlines into the strings like

Set BodyLine1="....\r\n"
0
 

Author Comment

by:Randy_R
ID: 33628390
Nope.  Just takes them as additional string characters.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 52

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 33628564
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
 
LVL 15

Expert Comment

by:mish33
ID: 33628573
0
 

Author Comment

by:Randy_R
ID: 33628746
That did it bp!  Thanks!
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 33628782
Great, glad that was helpful, thanks.

~bp
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 38136322
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

Featured Post

Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now