Can anyone explain what is happening here

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Can anyone explain what is happening here

#1 Post by Sounak@9434 » 05 Apr 2017 01:12

So guys I was playing around with batch macros and and am going to write a small topic about it at http://www.thebateam.org.

I was looking at almost all of my code but, I can't really make out what's happening in this common line.

Code: Select all

set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"


I know %LF% is a newline character(0x0A). But how can this line issue a newline with line continuation?

Can anyone write a step by step guide on what is happening here. Thanks in advance.

Sincerely,
Sounak

ShadowThief
Expert
Posts: 986
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Can anyone explain what is happening here

#2 Post by ShadowThief » 05 Apr 2017 05:18

Thankfully, you're on the site that invented that line.

viewtopic.php?p=7356#p7356

Jeb may have explained it at some point before that post, but that's the earliest one I can find.

Sponge Belly
Posts: 200
Joined: 01 Oct 2012 13:32
Location: Ireland
Contact:

Re: Can anyone explain what is happening here

#3 Post by Sponge Belly » 06 Apr 2017 13:03

Hello All!

In 2008, a Stack Overflow user asked how to echo a newline in Batch files. Someone called Ken posted this answer. This prompted a request for an explanation of how the code worked, but Ken was unforthcoming. So Jeb took up the slack and provided this now famous answer… two and a half years later? :?

HTH! :)

- SB

Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: Can anyone explain what is happening here

#4 Post by Sounak@9434 » 06 Apr 2017 22:39

@ShadowThief:, @SpongeBelly:

Thanks to both of you. I think I might have understood it.

set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
set \n=^%LF%%LF%^


So it creates an escaped linefeed with an caret at the end. Thanks :D

Post Reply