Page 1 of 1

Can anyone explain what is happening here

Posted: 05 Apr 2017 01:12
by Sounak@9434
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

Re: Can anyone explain what is happening here

Posted: 05 Apr 2017 05:18
by ShadowThief
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.

Re: Can anyone explain what is happening here

Posted: 06 Apr 2017 13:03
by Sponge Belly
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

Re: Can anyone explain what is happening here

Posted: 06 Apr 2017 22:39
by Sounak@9434
@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