Welcome!

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

SignUp Now!

Fixed multi-line alias issue

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]
 
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"
 
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
 
Why not just put the alias on a single line:

clearrecent=iff %@len[%RecentPath] GT 0 then & del /q "%RecentPath\*.lnk" & cls & endiff
 
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.
 
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?
 
"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.
 
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:
 
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.
 
Back
Top
[FOX] Ultimate Translator
Translate