mIRC Home    About    Download    Register    News    Help

Print Thread
$isalias inside on LOAD event #258277 23/06/16 03:36 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
Suppose you have a remote script A loaded with an alias like
Code:
alias test return A

If you load a remote script B, which has the following alias:
Code:
alias test return B
In this context were B is loaded after A, inside the on load event from remote file B, $isalias(test) will find the instance of the alias in B, which is wrong.

Last edited by Wims; 23/06/16 03:45 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $isalias inside on LOAD event [Re: Wims] #258280 23/06/16 05:33 PM
Joined: Jan 2004
Posts: 1,274
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,274
Why is that wrong? Alias B is available and preferred within the load event of file B - so why would it report A?

Re: $isalias inside on LOAD event [Re: Loki12583] #258281 23/06/16 05:41 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
Unsure why you think it's preferred, I don't think it's preferred at all, regardless of preference, it's a bug because $isalias does not work like that the rest of the time. $isalias return the first found alias, it shouldn't start returning another alias just because you're inside the on load event, otherwise one could even argu that $isalias() should return $null inside an on unload event if that alias is found in that unloaded file (and assuming no others file has that alias).
Only if the file was loaded and its order changed to be before the file A, it should return the alias in B.

Edit: this was found by westor, who wanted to make sure his alias was not currently in use by others script file, otherwise his script would just not work, so he checks $isalias inside on load and it's returning his own alias, I think this context shows how the behavior is not preferred at all.

Last edited by Wims; 23/06/16 05:50 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $isalias inside on LOAD event [Re: Wims] #258282 23/06/16 06:25 PM
Joined: Jan 2004
Posts: 1,274
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,274
I don't prefer the behavior, mIRC prefers the alias within its own file.

$isalias will return the alias defined in the current script in any event or alias, this is true in general and not limited to isalias: calling an alias defined both in the current script and somewhere else (order does not matter) the alias within the same script is called. Only if the alias is not defined within the current script will $isalias return one defined in another.

$null should not be returned in an unload event because the alias is still available within the event.

Code:
alias test return A
alias testA echo -ag $test $isalias(test).alias


Code:
alias test return B
alias testB echo -ag $test $isalias(test).alias
on *:load:{ echo -ag $test | echo -ag $isalias(test).alias | testB | testA }


Quote:
* Loaded script 'B.mrc'
-
B
test return B
B test return B
A test return A

Re: $isalias inside on LOAD event [Re: Loki12583] #258283 23/06/16 06:36 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
Wow, I didn't know about this, to me the first alias found should be executed, always, (unless local aliases are there).
So I'd call both bugs, but at least $isalias is behaving the same.

I certainly don't recall this behavior being there in the past, it also looks like a bug because that behavior seems to totally invalidate the usage of local aliases.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $isalias inside on LOAD event [Re: Wims] #258284 23/06/16 06:50 PM
Joined: Jan 2004
Posts: 1,274
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,274
That said, I do actually prefer the existing behavior. If I write a script and call an alias, why would I be attempting to call an alias in a different file instead of the one I've defined in my own? Marking an alias local simply stops it from being accessed by other scripts.

Re: $isalias inside on LOAD event [Re: Loki12583] #258286 23/06/16 07:22 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
You wouldn't. Well I feel like the current behavior isn't the behavior we used to have, that mIRC was looking for file in order to execute an alias, not that it would be first look into the file you are currently trying to call the alias from. I reported the bug in that sense.
Now it's likely that I assumed that behavior, where the current behavior has probably been there since ever.
However, there's still no way to accomplish what westor wanted to do, though that will probably lead to a feature suggestion.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $isalias inside on LOAD event [Re: Wims] #258294 23/06/16 09:07 PM
Joined: Dec 2002
Posts: 4,521
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,521
Thanks for your bug report. This is by design and has been the behaviour for as long as I can remember. As with most features, I cannot remember who requested a feature to work in a particular way or why they asked for it. However, as it took extra coding to make it work the way it currently works, I am guessing that someone specifically asked for it. As you know, I try not to change script-related features that may affect backward-compatibility, so this is not a behaviour that I would change.

Re: $isalias inside on LOAD event [Re: Khaled] #258296 23/06/16 09:11 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
Yes, there is no problem. I just thought the behavior was different, and that, therefore, $isalias should be consistent with that behavior, but since I was wrong, $isalias is actually working fine.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net