Welcome!

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

SignUp Now!

One line IFF ... Then ... Else ... EndIFF Statement issue in V17

Dec
231
2
I have following aliases:

xd=`iff %@index[%@attrib[%1],D] eq 4 THEN %+ cd %1 %+ ELSE %+ nd %1 %+ ENDIFF`
nd=md /s %1 && %1\​


If I am in a directory where "Test" does NOT exist and run the following with echo on:

xd Test​

V16:

iff %@index[%@attrib[Test],D] eq 4 THEN
md /s Test
Test\​

*** It creates the directory and I end up in the new directory.

V17:

iff %@index[%@attrib[Test],D] eq 4 THEN​

*** Nothing happens

If I change the xd alias to the following:

xd=`iff %@index[%@attrib[%1],D] ne 4 THEN %+ nd %1 %+ ELSE %+ cd %1 %+ ENDIFF`​

Now I run:

xd Test​

V16:

iff %@index[%@attrib[Test],D] ne 4 THEN
md /s Test
Test\​

V17:

iff %@index[%@attrib[Test],D] ne 4 THEN
md /s Test
Test\​


This tells me that V17 ignores the "%+ ELSE %+ nd %1 %+ ENDIFF" part of the alias.

I am using Build 51 for V17
 
I may have seen the same or a similar problem. An iff-then-else-endiff alias that used %+ as the command separator started failing with version 17. Since Rex said something about %+ being deprecated in version 17 (and requiring spaces before and after) and being discontinued in the future, I bit the bullet, changed my configuration to the default settings, and edited all my aliases and batch files to use explicit characters for multiple commands (&) and escapes (^). I have not noticed any problems since.
 
I changed it to

xd=`iff %@index[%@attrib[%1],D] ne 4 THEN && nd %1 && ELSE && cd %1 && ENDIFF`

and it works in both V16 and V17 but if you just type "xd" and return on the command line V16 will generate an error message about the syntax of "IFF" and returns to the command prompt but V17 generates the same error but never returns to the command prompt. The IFF failed because a syntax error and so the "&&" would cause the parser to ignore the rest of the line, that is a problem for the parser that is now looking for a "Else" or "EndIFF", but V17 parser doesn't handle it correctly and never returns to the prompt.

Probably the correct way to write this alias is:

xd=`iff %@index[%@attrib[%1],D] ne 4 THEN & nd %1 & ELSE & cd %1 & ENDIFF`

and Yes it works when there is a parameter, both V16 and V17 generate errors when there is no parameter and both return.
 
&& is a conditional AND; you should be using &.

Yes, I mentioned this in my previous email, and I even gave a reason I believe it failed, but the command line parser failed to return to the prompt when using the "&&" in the alias. The only way to terminate it was to kill the TCC session.
 
I am not able to reproduce that in build 52.
I got it on the first try. No prompt, and no amount of banging on Ctrl-C gets it back. And TCC is using all of one processor.
Code:
v:\> ver

TCC  17.00.52  Windows 7 [Version 6.1.7601]

v:\> alias xd=`iff %@index[%@attrib[%1],D] ne 4 THEN && nd %1 && ELSE && cd %1 && ENDIFF`

v:\> xd
TCC: (Sys) The parameter is incorrect.
""
Usage : IFF [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] THEN & commands
 
Why not for

xd=`iff %@index[%@attrib[%1],D] ne 4 THEN && nd %1 && ELSE && cd %1 && ENDIFF`

try this

xd=`iff not isdir "%1" then && nd "%1" && else cd "%1" && endiff
 
I am not able to reproduce that in build 52.

Well I tested it again using build 52 and it doesn't return to the prompt.

upload_2014-11-13_8-30-18.png


Seems to die at the "&&" when it reaches "iff %@index[%@attrib[%1],D] ne 4 THEN && nd %1 &&"
 
Last edited:
Why not for

xd=`iff %@index[%@attrib[%1],D] ne 4 THEN && nd %1 && ELSE && cd %1 && ENDIFF`

try this

xd=`iff not isdir "%1" then && nd "%1" && else cd "%1" && endiff

Thanks this wasn't my original definition for the alias either. Your version is both cleaner and does a better job of indicating what it does, but strangely I was looking for complexity and in some case the unusual because I have actually been testing the new V17 parser. I have actually been trying to break the TCC parser, for example the xd alias with "&&" may have the correct syntax but since "&&" is a short circuit conditional, how would the parser handle the fact that the IFF may or may not be terminated with a "EndIFF".
 
I can confirm that I see the same behavior. That instance of TCC locks up and cannot be recovered using ESC or Ctrl-C.
 

Similar threads

Back
Top