alias terminating before it should

Jun 3, 2008
127
3
Temecula, CA
I have this alias I've created for testing purposes called UpUtils. Its purpose is to update several locations where I have my utilities directory stored - some on other computers, some on USB devices. (In the alias below, D, F and K are potentially USB drives, although any number of them might be connected to the computer at any given time.)

UpUtils=echo Q: %+ *copy /u /h /e /y /s C:\Utils Q:\Personal\MFerguson\Utils %+ echo D: %+ if %@ready[D:] == 1 if isdir D:\Utils *copy /u /h /e /y /s C:\Utils D:\Utils %+ echo F: %+ if %@ready[F:] == 1 if isdir
F:\Utils *copy /u /h /e /y /s C:\Utils F:\Utils %+ echo K: %+ if %@ready[K:] == 1 if isdir K:\Utils *copy /u /h /e /y /s C:\Utils K:\Utils %+ echo R: %+ if isdir R:\Utils *copy /u /h /e /y /s C:\Utils R:\Utils


I've added debugging stuff to the alias to help troubleshoot what's going on - I don't need the echo part of each command, nor would I expect to have to include the %@ready part, since I would think that isdir would cover it. But when I execute this alias, with a D: drive and a K: drive existing but no F:, I expect it to list Q:, then D:, the F:, then K: then R:. I only see Q:, D: and F:, and the actual file copy (copies) for F: doesn't even happen, and no K: or R:. It seems that when it hits the 'if isdir F:\Utils' statement, it terminates the alias completely. No error message or anything like that.

TCC 16.03.55 x64 Windows 7 [Version 6.1.7601]
TCC Build 55 Windows 7 Build 7601 Service Pack 1
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
You are better off making that a BTM script and using your alias to invoke the script. The alias is evaluated all at once as a single command line statement and the IF processing doesn't have any ELSE's. So if the IF is false, it's going to stop right there.

UpUtils.btm:
Code:
gosub DoUpdate Q:\Personal\MFerguson\Utils
gosub DoUpdate D:\Utils
gosub DoUpdate F:\Utils
gosub DoUpdate K:\Utils
gosub DoUpdate R:\Utils
quit

:DoUpdate [dest]
echo %@drive[%dest]
iff %@ready[%dest] == 1 then
    if isdir %dest *copy /u /h /e /y /s C:\Utils %dest
endiff
return
 
Jun 3, 2008
127
3
Temecula, CA
You are better off making that a BTM script and using your alias to invoke the script. The alias is evaluated all at once as a single command line statement and the IF processing doesn't have any ELSE's. So if the IF is false, it's going to stop right there.

Thanks, Scott. I didn't know the 'if' (not 'iff') statements were short-circuit. That certainly explains it.

Of course my older version of TCC doesn't have the %@drive[] function, but I can easily take it from here.
 
Jul 29, 2016
49
1
It might also be because "Duplicate CMD Bugs" is turned on. CMD will end all further processing of the command line if an IF condition is found to be false, even if there are command separators after the IF command and between any following commands. Turning off "Duplicate CMD Bugs" or using IFF instead of IF would probably solve it.
 
Similar threads
Thread starter Title Forum Replies Date
D Can alias pass parameters to for command? Support 3
Jay Sage Issue with CD_ENTER Alias Support 37
Jay Sage Issue with CD_LEAVE Alias Support 3
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
R @select inside alias gives different (insanely small) window Support 7
kb6ojs ALIAS with multiple commands? Support 9
vefatica Can I alias @@Ctrl-Shift-Alt-u? Support 4
D Alias with setdos no longer works Support 21
vefatica TPIPE in an alias? Support 2
Peter Murschall TCC V26.01.3x Debugging has problems with Alias /R Support 1
Peter Murschall CMDebug 26.01.37 has problems with Alias Support 21
samintz How to? Alias or prompt? Support 1
MickeyF expand alias in cmdline with Ctrl-F in TCC Support 21
Jay Sage Directory Alias Access to FTP Servers Support 2
rps How to? Shralias and producing history.sav, alias.sav .. Support 6
J Alias @@F5 hotkey Support 2
vefatica alias.sav not accurate Support 8
Joe Caverly Using a Directory Alias with @iniwrite fails Support 14
N multiple command alias and redirection Support 0
vefatica SETLOCAL ... ALIAS ... pipes Support 2
B TCC 21.01.50 Problem with ALIAS /r and SET /r Support 2
rps How to? Alias/Command line use of *log on/off Support 2
JohnQSmith ALIAS /R in TCSTART.BTM Support 9
D Alias in batch file Support 3
vefatica Can't execute @ALIAS[...] Support 5
E How to? Load Alias File on Startup Support 3
I Windows 10 console does not allow alt-F4 alias to complete Support 1
MickeyF create an alias with optional parameter Support 4
nickles Alias expansion Support 7
T scrput `` in alias or function Support 2
vefatica Alias works differenltly v16 vs. v17 Support 13
B Alias with multi line definitions not assigned Support 6
jbanaszczyk Alias with space in the name Support 3
jbanaszczyk Alias for internal command Support 8
D Clear alias parameters Support 7
T Fixed multi-line alias issue Support 13
keithg1964 WAD 16.0027 Alias /rz bug Support 8
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
tmaynard How to? Control-U alias for Escape (command line editing) Support 5
C Alias ListEmptyFldrs=??? Support 4
M How to? Put logic into an alias... Support 6
G How to? v15: Can't alias Alt-Z Support 7
nikbackm v15: Problem with ALIAS in command group Support 10
vefatica WAD DO i=1 TO %# in an alias? Support 9
cgunhouse Directory Alias Issue Support 7
C CMD window size and post_exec alias ? Support 6
deleyd How to? Alias in TCMD.INI file? Support 2
M How to? Run a command (alias, actually) on a "timed" basis... Support 13
A strange error in alias Support 9
J Initialise; Alias; Extended directory search Support 2

Similar threads