1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Command grouping in for... loops

Discussion in 'Support' started by epement, Apr 26, 2010.

  1. epement

    Joined:
    Jun 28, 2008
    Messages:
    67
    Likes Received:
    2
    In a for ... in ... do (...) loop with command grouping, when multiple commands are wrapped in the parentheses grouping, what are the limits to what or how much can be placed in the parentheses?

    Is is strictly a character count or what? I have had a batch file that seemed to work fine when I had, say, 20 lines in the parenthetical grouping, but now that I have added additional lines, the command fails. The help message just says improper syntax. So I'm wondering whether I'm trying to put too much stuff in the (parentheses).

    What are the limits, restrictions, etc., to command grouping?

    Eric
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    | What are the limits, restrictions, etc., to command grouping?

    All the limitations on sizes are in HELP topic "limitations.htm". RTFM.
    --
    HTH, Steve
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,358
    Likes Received:
    39
    A command group is essentially one long command line, even if you split it across several physical lines. Twenty lines in one logical line seems a little excessive; I'd recommend rewriting it as a DO loop.
     
  4. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    Aside from the actual limits that Steve pointed out, you would be better
    off re-writing your FOR loops using DO loops in TCC. This make debugging
    substantially easier because it allows you to single step through the
    statements within the loop. Plus it eliminates the limit on compound
    statement length and instead each line has its own limit.

    -Scott

    epement <> wrote on 04/26/2010 10:13:17 AM:


    (parentheses).

     
  5. epement

    Joined:
    Jun 28, 2008
    Messages:
    67
    Likes Received:
    2
    Sorry, I was looking under "help for". My mistake.
     
  6. epement

    Joined:
    Jun 28, 2008
    Messages:
    67
    Likes Received:
    2
    I believe this is probably the solution to my question. Thanks, Scott (and Charles), for suggesting the DO loop as a better way handle this.

    Eric
     

Share This Page