mIRC Homepage
Posted By: Wims $v1 behavior - 03/03/08 01:40 AM
considering this alias :

Code:
alias Ga {
if (!$+($null,1)) { noop }
echo -a $v1
if ($+($null,1) == $null) { noop }
echo -a $v1
}
After both /if, $v1 should be 1, but it return 0 when using the !.
Posted By: Bekar Re: $v1 behavior - 03/03/08 04:05 AM
Why? The first is negated (!).

The $null means nothing when concatenated with another value (i.e. it's stripped/ignored).

As $v1 is the first part of the comparison, I see no problems here.

If you're wanting the $null to actually mean something, then use binary variables.
Posted By: argv0 Re: $v1 behavior - 03/03/08 05:33 AM
$+($null,1)
== $null $+ 1
== 1

!1 == 0 (note this wont work *literally* because of mirc parsing issues, this is the case for !$(1) though)

all of the above are facts, not assumptions.

therefore

if (!$+($null,1)) == if (0)

$v1 seems to be 0 here.

where's the bug?
Posted By: Wims Re: $v1 behavior - 03/03/08 03:35 PM
If (!$(1)) is the same as if (0) but it's because of the !, imo, in first case, $v1 is 1 and 0 in the second.It's just how i seen this, if it's normal behavior, i'll simply use "== $null" instead of the "!"





Posted By: jaytea Re: $v1 behavior - 03/03/08 03:53 PM
i've also had cases where i would've preferred $v1 to return 1 instead of its negation, but i've come to accept it. "!$+()" is the whole parameter to the if condition, and the definition of $v1 is 'the first parameter of an if condition', so the behavior does make sense

you could use == $null, but of course checking (%x == $null) isnt the same as (!%x). in cases where you absolutely need to check (!%x), but would like %x to be filled as $v1 you could use:

Code:
if (%x) /
else {
  ; stuff with $v1
}


or set variables, and so on
© mIRC Discussion Forums