Results 1 to 5 of 5

Thread: Continuation Lines in Batch Files

  1. #1
    Join Date
    Feb 2007
    Beans
    Hidden!

    Continuation Lines in Batch Files

    Hi All,

    I have a pretty basic question about MS batch files. Do batch files support any kind of continuation line analogous to the way you can continue a line in a bash script (ending the line with a backslash)? I've already verified that the command interpreter (cmd.exe) does not like backslash. And I've not been able to find anything via a Google search.

    Thanks in advance for any help/advice.

  2. #2
    Join Date
    Dec 2005
    Location
    USA
    Beans
    886
    Distro
    Ubuntu

    Re: Continuation Lines in Batch Files

    Not too my knowledge - should be easier to just keep one line to one line...

    -Richard
    I use both Windows and Linux. Is that a crime? || Ubuntu User # 16597

  3. #3
    Join Date
    Feb 2007
    Beans
    Hidden!

    Re: Continuation Lines in Batch Files

    Quote Originally Posted by rickyjones View Post
    Not too my knowledge - should be easier to just keep one line to one line...

    -Richard
    Thanks for your response.

    I was trying to keep the file readable. I guess I will just have to let the lines wrap.

  4. #4
    Join Date
    Mar 2008
    Beans
    6

    Re: Continuation Lines in Batch Files

    You can use a carat character ("^" ; shift-6) as a line extension character in DOS batch files. Be sure to save them with CR/LF line endings - "textmode" in VIM.

  5. #5
    Join Date
    Feb 2007
    Beans
    Hidden!

    Re: Continuation Lines in Batch Files

    Quote Originally Posted by tom93 View Post
    You can use a carat character ("^" ; shift-6) as a line extension character in DOS batch files. Be sure to save them with CR/LF line endings - "textmode" in VIM.
    Thanks a lot. I apologize for my delay in responding; I wasn't in a position to test your suggestion until now.

    For anybody else wanting to do this, I'll note that apparently the continuation line cannot have any leading blanks. So that this works:

    Code:
    for /F "tokens=1,2,3,4,5" %%a in (%temp_lines%) ^
    do call :sub2 %%a %%b %%c %%d %%e
    but this does not:

    Code:
    for /F "tokens=1,2,3,4,5" %%a in (%temp_lines%) ^
       do call :sub2 %%a %%b %%c %%d %%e
    (It may not be obvious from this posting but in each case the caret is the last character on the line. I presume that is a requirement analogous to bash but I haven't tested it.)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •