Broken For and nested Do

Jun 8, 2013
Warsaw, Poland
/me again

Please help how to solve this issue.

TCC/LE 13.06 and TCC 17:

Simple For loop:
*For /l x in (1,1,3) do (
   *echo FOR
Works fine.

Simple Do loop:
*Do 5
   *echo DO
Works fine.

Mixed together:
*For /l x in (1,1,3) do (
   *echo FOR
   *Do 5
     *echo DO
The result is
while I expected 18 lines.

Of course - real case is not so simple. I need For loop due to For /R switch (I can't find similar Do loop).

Best regards.


Staff member
May 14, 2008
A FOR is a single-line statement (the lines are all appended before the command is executed). A DO (unless you're using the single-line DO syntax, which you are not) is always a multiline statement.

So if you're going to embed a DO in a FOR, use the single-line DO syntax. Otherwise, a (much) better idea is to replace FOR /R with DO /S (possibly combined with /D depending on what you're trying to do).
Similar threads
Thread starter Title Forum Replies Date
vefatica Batch parameters broken? Support 2
Charles Dye Command grouping broken? Support 8
Dick Johnson DrawBox now broken in Windows 10? Support 6
D Theme support partially broken? Support 1
E Fixed View command broken in version 21.0 build 22 Support 9
rps Documentation Regular expression syntax link broken Support 1
C WAD TABCOMPLETE broken? Support 4
A Latest TCC/LE install broken Support 1
WadeHatler pdir broken in 19.1 for directories with spaces Support 1
vefatica Documentation Help: XML link still broken Support 0
vefatica WAD Help Search broken? Support 3
J Vers. 18 Here doc redirection broken? Support 4
nikbackm VIEW broken in v18 + Windows 10 Support 8
L Fixed FindFirst/FindNext broken, 17.0 Support 2
nickles Fixed @regexsub[] broken Support 2
rps Command Input Window tab completion broken Support 7
vefatica Uservoice ... broken? Support 8
vefatica IFTP problems (broken pipe?) Support 24
yjchung Filename completion broken?? Support 1
B WAD tab navigation broken Support 3
M Web Help option in Take Command 15 broken? Support 3
Charles Dye Low priority to Rex: broken graphic Support 7
Dmitry L. Kobyakov How to clean from the broken updating? Support 3
nickles RegExp in FOR broken Support 10
A TCC/LE Broken Support 20
tmaynard WAD Leiningen broken with TCC (but OK with CMD) Support 12
W /g option (%) on MOVE cmd appears broken TCC 14.03.57 x64 Support 8
nickles Fixed Functionality broken with v54 Support 7 Option: Updates broken in Build 36 Support 3
vefatica WAD DIR ftp ... broken Support 2
vefatica Fixed Binary buffers broken? Support 0
C STDOUT seeming broken in TCC.EXE! Strangest behaviour ever! Support 6
vefatica Help broken? Support 2
Daniel Wee Rexx output redirection seems to be broken Support 4
J Problem with broken alias Support 3
p.f.moore Broken email access to these forums - finally giving up Support 4
B Problem with color in nested shells Support 1
R Problem with %_do_loop in nested do loops Support 2
C Nested IF syntax — TCC behaving differently to CMD Support 12
C FOR loop with nested IF / IFF Support 9
vefatica _DO_LOOP and nested DOs? Support 8
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
vefatica Single-line DO inside nested multi-line DOs? Support 9
R How to? debug a nested batch file Support 2
G WAD Nested if exits enclosing if Support 3
M A problem with nested Gosub's/ExecStr's Support 14
C CMD's "nested quote" syntax Support 3
dcantor Terminology question: nested vs. recursive Support 0
R nested for loop question Support 3
J Nested for loops and quotes Support 12

Similar threads