mIRC Homepage

$isalias inside on LOAD event

Posted By: Wims

$isalias inside on LOAD event - 23/06/16 03:36 PM

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.
Posted By: Loki12583

Re: $isalias inside on LOAD event - 23/06/16 05:33 PM

Why is that wrong? Alias B is available and preferred within the load event of file B - so why would it report A?
Posted By: Wims

Re: $isalias inside on LOAD event - 23/06/16 05:41 PM

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.
Posted By: Loki12583

Re: $isalias inside on LOAD event - 23/06/16 06:25 PM

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
Posted By: Wims

Re: $isalias inside on LOAD event - 23/06/16 06:36 PM

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.
Posted By: Loki12583

Re: $isalias inside on LOAD event - 23/06/16 06:50 PM

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.
Posted By: Wims

Re: $isalias inside on LOAD event - 23/06/16 07:22 PM

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.
Posted By: Khaled

Re: $isalias inside on LOAD event - 23/06/16 09:07 PM

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.
Posted By: Wims

Re: $isalias inside on LOAD event - 23/06/16 09:11 PM

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.
© 2019 mIRC Discussion Forums