Fixed multi-line alias issue

May 20, 2008
456
2
#1
My alias file has some that are multi-line. Here is one example:
Code:
 clearrecent= & ^
    iff %@len[%RecentPath] GT 0 then & ^
       del /q "%RecentPath\*.lnk" & ^
       cls & ^
    endiff
All my my aliases in the file that start with ...= & ^ are no longer being loaded by alias /r. Other aliases in the file, even after these, are loaded as expected.

ver /r
TCC 16.00.30 Windows 7 [Version 6.1.7601]
 
#2
I can comfirm this. With v15, all's well.
Code:
v:\> ver

TCC  15.01.58  Windows 7 [Version 6.1.7601]

v:\> tail /n2 h:\ShrDump\alias.sav
zz=echo foo & ^
echo bar

v:\> alias /r h:\ShrDump\alias.sav

v:\> alias | tail /n1
zz=echo foo & echo bar

v:\> zz
foo
bar

v:\> unalias zz
With v16 ...
Code:
v:\> ver

TCC  16.00.30  Windows 7 [Version 6.1.7601]

v:\> tail /n2 h:\ShrDump\alias.sav
zz=echo foo & ^
echo bar

v:\> alias /r h:\ShrDump\alias.sav

v:\> alias | tail /n1
echo=bar

v:\> alias zz
TCC: Not an alias "zz"
 
#3
And "FUNCTION /R" exhibits similar behavior. Comparing v16 to v15 ...
Code:
v:\> ver

TCC  16.00.30  Windows 7 [Version 6.1.7601]

v:\> type h:\ShrDump\Function.sav
zz=%@right[^
3,foobar]

v:\> function /r h:\ShrDump\Function.sav

v:\> function
TCC: No functions defined
Code:
v:\> ver

TCC  15.01.58  Windows 7 [Version 6.1.7601]

v:\> type h:\ShrDump\Function.sav
zz=%@right[^
3,foobar]

v:\> function /r h:\ShrDump\Function.sav

v:\> function
zz=%@right[3,foobar]

v:\> echo %@zz[]
bar
 
May 20, 2008
456
2
#5
Why not just put the alias on a single line:

clearrecent=iff %@len[%RecentPath] GT 0 then & del /q "%RecentPath\*.lnk" & cls & endiff
I do combine the lines sometimes. For my OP, I used a relatively simple 'real' example. There are much longer aliases with multiple nested blocks. The more lines there are, the easier it is to read/edit when those lines are separated.
 
#10
Yes, multiline may be more readable, but I always* figured that overly complex aliases ought to be batch files. Furthermore, when there is neither elseiff nor else branch I normally use a simple if and - if needed - a command group in parentheses, which are easily discernible by the eye.
"Always*" - not in 4DOS days, just since drives became very fast and very efficiently buffered, or when I could use a virtual disk in internal storage.

Rex, what about the issue of multiline aliases not loading with alias /r without /z?
 
May 20, 2008
456
2
#11
"Always*" - not in 4DOS days, just since drives became very fast and very efficiently buffered, or when I could use a virtual disk in internal storage.
Some of these date back to 4DOS and, when a pattern is set, the next variation may follow that pattern. I typically use an alias if it does not set any internal environment variables or if any nested commands are not also externally used and might work better as a gosub.
 
May 31, 2008
382
2
#12
Rex, you marked this issue fixed. I tested v. 16.00.32 but I'm still having problems. The following fragment from my alias file ends up redefining ECHO
Code:
file.p2clip=^
*echo %@full[%@if[0 == %@len[%@path[%1]],%_cwd\]%@filename[%1]] >clip:
 

rconn

Administrator
Staff member
May 14, 2008
10,646
97
#13
Rex, you marked this issue fixed. I tested v. 16.00.32 but I'm still having problems. The following fragment from my alias file ends up redefining ECHO
Code:
file.p2clip=^
*echo %@full[%@if[0 == %@len[%@path[%1]],%_cwd\]%@filename[%1]] >clip:
That works fine here. Do you have any trailing whitespace on the first line?
 
May 31, 2008
382
2
#14
Meanwhile I have switched to another PC and it is working now. So, maybe earlier today I had not properly reset the environment after upgrading from build 30 to build 32. I'll let you know if it happens again. Thanks.