mIRC Home    About    Download    Register    News    Help

Print Thread
#270841 10/10/22 02:47 PM
Joined: Sep 2015
Posts: 100
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 100
Here's an example, made in clear mirc:

Code
alias test {
  $iif(%test == $null,%test = test)
  echo -a %test
}
alias test2 {
  $iif(%test2 == $null,set %test2 test2)
  echo -a %test2
}
alias test3 {
  if (%test3 == $null) %test3 = test3
  echo -a %test3
}
alias test4 {
  if (%test4 == $null) set %test4 test4
  echo -a %test4
}

When i perform /test, appears an error:

Quote
* /=: not connected to server (line 2, remote.ini)

When i perform /test2:

Quote
* /set: invalid parameters (line 6, remote.ini)

When i perform /test3 și /test4 all works!

So, is a bug with $iif() that not evaluate the commands in it? I used mirc version 7.64 till this new version 7.71 and $iif(%test == $null,%test = test) works fine!

Last edited by klez; 10/10/22 02:49 PM.
klez #270842 10/10/22 03:06 PM
Joined: Feb 2011
Posts: 424
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 424
After some quick testing it seems this issue started in v7.67.

I'm guessing this caused it:

Quote
11.Fixed how /set/unset/inc/dec/timer/sockread %vars are evaluated
in some contexts.

KindOne #270843 10/10/22 03:07 PM
Joined: Sep 2015
Posts: 100
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 100
Ohh shit.. i undertsand.. but take attention that set,inc etc. works fine.. here is the problem in $iif() not in set.. because in if () works fine and $iif() results bugs.. see my examples!

Last edited by klez; 10/10/22 03:12 PM.
klez #270844 10/10/22 03:22 PM
Joined: Feb 2011
Posts: 424
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 424
I've only posted to help figure out when the issue started.

Best to wait for Khaled to respond.

klez #270845 10/10/22 04:16 PM
Joined: Jul 2006
Posts: 3,971
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,971
This is going to be tricky...

One needs to understand that what's going on here should not be viewed as a bug, you're inside an identifier, $iif, it is normal behavior for $iif to evaluate the 'iftrue' parameter of $iif.

Of course, this has nothing to do with $iif, all identifiers will behave the same way (more or less).

I'm afraid mIRC is now getting it correctly, you can use $iif(%test == $null,set % $+ test test) if you want to set the variable inside $iif.

Note that $iif is a super slow identifier anyway, as it's calling /if internally, the proper, and therefore much faster way to do a condition and set a variable accordingly is what you did in the test3 and test4 alias.

There still might be some concern though, because $iif(1,% $+ test = 1) executed as a command sends %TEST to the server, it does not set, whereas $iif(1,set % $+ test 1) will set correctly, probably related is that $(%a = 1) used to return "set %a 1", and no longer does (return "= 1"), which should never be an issue in itself.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
klez #270846 10/10/22 04:45 PM
Joined: Dec 2002
Posts: 5,244
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,244
The change in v7.67 was made due to how variables were being evaluated/not evaluated by /set/inc/dec/etc. in different contexts. See here for the original discussion.

The issue with $iif() was discussed here some time ago.

The problem is that the items in $iif() are parameters, so they need to be evaluated, in the same way as all identifiers have their parameters evaluated.

Khaled #270847 10/10/22 06:22 PM
Joined: Sep 2015
Posts: 100
klez Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Sep 2015
Posts: 100
The issue that i must replace tons of lines where i have $iif(%var == $null,%var = 1) to if (%var == $null) %var = 1 or to $iif(%var == $null,set $chr(37) $+ var 1) .. i located that if i unset %var before $iif() also works.. but is the same to make changes. Although, I thought is a way to change this issue to avoid the break of the existing scripts.

Last edited by klez; 10/10/22 06:29 PM.
klez #270851 10/10/22 08:47 PM
Joined: Jan 2004
Posts: 1,997
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,997
I assume you read the link, and the link in the link. This wouldn't be the 1st time that scripts using wrong syntax that works ended up having a broken script when that was fixed.

I had a script I'd made in the version 6.x era where I had unknowingly had a line in a popups label having an extra closing parenthesis. Everything was fine through several versions, until one day I was flooded with irritated users who had a flood of error messages in their status window, because they'd upgraded to a newer version that was no longer forgiving of the extra parenthesis. Luckily in that case it was simple to fix.

If this were to change to support the old broken syntax, then either people who've been using the new+correct syntax will now be broken, or else mIRC would be forced to support all of:

$iif(%test2 == $null,set -s % $+ test2 test2)
$iif(%test2 == $null,set -s %test2 test2)
$iif(%test2 == $null,set % $+ test2 test2)
$iif(%test2 == $null,set %test2 test2)

And also doing the same for /inc /dec /sockread /sockread

And just an observation about the

%test = test

..syntax in your example. I know it's valid, but I prefer not to use it, because it's more ambiguous as to whether the intent is to be setting a %global or %local variable. I most commonly see this form used by new scriptors who don't realize that doing this is creating global variables that they don't realize are being set, where they can either cause problems for another script that erroneously didn't initialize their variables, or else this stuff ends up bloating up the vars.ini with stuff that goes global but never gets cleaned up.


Link Copied to Clipboard