Command grouping in for... loops

#1
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,719
47
Albuquerque, NM
prospero.unm.edu
#3
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?
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.
 

samintz

Scott Mintz
May 20, 2008
1,312
11
Solon, OH, USA
#4
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:


> 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 find 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
>
>
>
>
 
#6
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.
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