Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

FOR loop with nested IF / IFF

Hello

Prior to version 18, the following batch file snippet would display 1, 2, 3 on seperate lines. With version 18.32 however, only the first line is printed. If I change the condition to "1 EQ 1" then all three lines are printed.

I've tried this with TCC-13 and all three lines are printed, as I would have expected.

Is this the expected behaviour, or is this a regression in version 18?

@ECHO OFF

FOR %a IN (1 2 3) DO (
ECHO %a

IFF 1 EQ 0 THEN
ECHO.
ENDIFF
)


Thank you!

Chris
 
I'm not sure what you're trying to do -- when would that test ever be true? -- but I wouldn't put a (multiline) IFF block inside a (single-line) FOR block. I'd substitute DO for the FOR.
 
Hello Charles

It's not the actual batch file that I was executing. It's a stripped-down example to illustrate the problem, with a hard-coded test that's always false.

Basically, if the FOR / DO loop contains an IF or IFF statement that evaluates to false, TCC seems to be bailing out of the rest of the loop without processing the other values in the loop.

Chris
 
It's OK here.
Code:
v:\> type mline.btm
@ECHO OFF

FOR %a IN (1 2 3) DO (
ECHO %a

IFF 1 EQ 0 THEN
ECHO.
ENDIFF
)

v:\> mline.btm
1
2
3
 
Hello Vince

Which version of Take Command / TCC are you using? I am using version 18, and experiencing this problem. With version 13, the batch file works as expected.

Chris
 
Hello Charles

Apologies, I only replied to the first part of your comment yesterday. I will most likely adapt the batch file to use DO instead of FOR, but this is a previously-working script that I just happened to run for the first time with TC 18 the other day. I think I previously wrote it with either version 16 or 17, but as I commented previously it works as expected on version 13 too. I take your point about using IF / IFF in a FOR loop, but I was using parentheses to create a command group, as per a similar example in the online help for the FOR command.

Chris
 
Hello

Prior to version 18, the following batch file snippet would display 1, 2, 3 on seperate lines. With version 18.32 however, only the first line is printed. If I change the condition to "1 EQ 1" then all three lines are printed.

Not reproducible here (v18.00.32, x64, Windows 10).

Are you using the same options in TCMD.INI?
 
I don't see the behavior you describe. I don't see it even if I change the IFF to IF and turn DuplicateBugs on, though I would expect it to fail in that case.

You don't have any aliases for FOR or IF, do you? Of course not; that would be crazy. How about SETDOS?
 
Hello all

I checked my TCMD.INI as per Rex's suggestion, and there was no setting for DuplicateBugs. Adding DuplicateBugs=No to the [4NT] section of this file has resolved the problem.

Thanks very much to all of you for your help with this.

Chris
 

Similar threads

Back
Top