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

Dec 2, 2008
224
2
Canada
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
 
Jun 2, 2008
376
2
Newton, MA
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.
 
Dec 2, 2008
224
2
Canada
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.
 
Dec 2, 2008
224
2
Canada
&& 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.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
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
 
Apr 2, 2011
1,441
10
54
North Carolina, USA
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
 
Dec 2, 2008
224
2
Canada
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:
Dec 2, 2008
224
2
Canada
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".
 
Jun 2, 2008
376
2
Newton, MA
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
Thread starter Title Forum Replies Date
T VIEW only works from command line Support 14
vefatica `Back quotes` - command line vs. batch file Support 5
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
D How to use multi-line DO to loop through first level directory names Support 5
D Open Windows 10 Photos app from command line Support 11
Peter Murschall Single-line Do-CMD is a bit uncooperative. Support 6
Jesse Heines Strange Line Wrapping Behavior Support 14
fpefpe How to? command echo in title line/bar Support 2
vefatica Command line DO with no closing parenthesis? Support 9
R Long commands retrieved from command history have blank line when wrapped Support 20
M No line wraps if last line of the screen buffer is reached Support 5
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
R CMDebug, dark theme, current line Support 7
vefatica IDE - when breakpoint is on a blank line? Support 3
D Double Quote in TC Tool Bar Button Command line Support 3
Joe Caverly Expand all aliases on the command line Support 2
vefatica How do I do this with a multiple-line DO? Support 7
Jay Sage Cannot Postion Cursor in Command Line Using Mouse Support 7
vefatica Windows 10 and line wrapping selection? Support 6
vefatica IDE.EXE's command line? Support 19
x13 TPIPE /REPLACE - Remove line (including EOL) Support 3
D btm file command line augments comparing for string or math. Support 12
D Grabbing html text with @line Support 3
Chen Touboul Overtyping issue - i press the Insert key, help till press enter for new line in TCC Support 2
vefatica FFIND and multi-line regular expressions Support 4
P Escape key no longer clears command line in v24 Support 21
J File explorer handling from command line? Support 2
M Ctrl-C when using command line history does nothing Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
C Replace 1st argument on command line Support 4
vefatica Library functions and line continuations? Support 4
Joe Caverly Works in debugger, not from cmd line Support 1
P No linefeed on last line of console window Support 2
K Command Line Selection Not Working Support 12
J Error running Python at command line Support 9
Joe Caverly PSHELL Blank Line Display Support 2
rps How to? Alias/Command line use of *log on/off Support 2
x13 //directive ignored on TCC command-line Support 4
Joe Caverly Unicode, Codepage 437, and line characters Support 3
J How to? max. practical command line length? Support 3
mfarah WAD Odd behaviour with command-line arguments on TCMD. Support 7
T Regex engine doesn't recognize native DOS line endings Support 2
thorntonpg F1 on command line The webpage cannot be found Support 5
J Python: TCC command line parsing removes '=' equal sign characters Support 4
L Fixed console line length in Take Command 19? Support 3
C LOG entry for TCMD/TCC command line Support 15
fpefpe Documentation Can the title line of tcmd be set? Support 4
H command line parsing question Support 5
dcantor How to make line numbers fixed width in FFIND Support 11

Similar threads