mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2010
Posts: 29
P
Plornt Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
When using $isalias it does not return the full alias definition when using the .alias property. It appears somewhat inconsistent depending where your alias is and if it uses multiple lines.

If its in the alias's file and its one line:
Code:
/h /echo -a Hey

$isalias(h).alias returns: /echo -a Hey


If its in the alias's file and its multiple lines:
Code:
/h {
echo -a Hey
}

$isalias(h).alias returns: {


If its in the remotes file and its single line:
Code:
alias example { echo -a Hey }

$isalias(example).alias returns: example { echo -a Hey }


(Multiline also doesnt work in remotes but its pretty much the same as above except returns: example { )

So as you can see it always removes the first "token" of the alias line which is completely inconsistent due to the alias keyword in remotes. Plus it doesnt give you the full alias. It appears this functionality is pretty much useless.

That being said, I have no idea how you would handle multiline alias code...

Last edited by Plornt; 02/11/15 12:06 PM.
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
You're not wrong, but as usual it'll be hard to tell whether changing this breaks any existing scripts.. Just a thought: perhaps this can be resolved by extending $isalias() with two properties in addition to .fname: .fline, returning the line number of the alias definition, and .fscript, returning whether the containing file is loaded as a script file (as opposed to an aliases file). Then any script that wants the full alias definition can simply use $read() to get the contents itself.. assuming it manages to find the end of the alias (perhaps a .flines property would be in order as well then).


Saturn, QuakeNet staff
Joined: May 2010
Posts: 29
P
Plornt Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
Yeah, its just hard to believe anyone would ever have used it with how its current functionality is done. I mean, I guess the single line alias's are fine but anything other than that is entirely useless so I dont see what scripts could have used it as is.

I do like the solution of having a line number and line ending though!

Last edited by Plornt; 02/11/15 12:36 PM.
Joined: Dec 2002
Posts: 252
T
Fjord artisan
Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
You could do your own parsing still and determine which type of file is loaded. using $isalias(alias in question).fname yields the file in which it exists. You can utilize $script(fname return) and $alias(fname return) to determine if it's loaded as a remote script file, or within an alias file as one will return null, where the other will return the exact same filename.

It'd take a bit of tinkering to parse out what you're looking for, especially since you have various types like ini, and plain text, so you may need to filter out [groups] and nX= depending on if the file type is of INI structure.

There's a number of possible solutions to achieve this, using $read(), /filter, or even /bread along with $bfind() (the last being the one i'd probably try, since you could parse out what you need without looping, or special cases in a custom alias for /filter)

As for a modification solution that wouldn't break previous scripts, i'd suggest a 2nd parameter within the $isalias() call, IE:

$isalias(aname).alias <== same support, but if you suspect it's multi-line:

$isalias(aname,0).alias <== returns how many total lines define the alias

$isalias(aname,N).alias <== returns the Nth line that defines said alias.

Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks for your bug report. As this has been the behaviour for a long time, it will be difficult to change as scripts may already handle the different formats. However, I will add an .ftype property that returns the type of file the alias is in and the suggested $isalias(alias,N) to return the lines in a multi-line alias. This should be in the next version.


Link Copied to Clipboard