mIRC Home    About    Download    Register    News    Help

Print Thread
$v1 behavior #195821 03/03/08 01:40 AM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
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 !.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $v1 behavior [Re: Wims] #195825 03/03/08 04:05 AM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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.

Re: $v1 behavior [Re: Wims] #195826 03/03/08 05:33 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
$+($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?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: $v1 behavior [Re: argv0] #195836 03/03/08 03:35 PM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
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 "!"







Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $v1 behavior [Re: Wims] #195837 03/03/08 03:53 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
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


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde