mIRC Home    About    Download    Register    News    Help

Topic Options
#261883 - 06/12/17 08:57 PM Does mIRC help file doesn't contain mistakes? :)
klez Offline
Babel fish

Registered: 08/09/15
Posts: 72
Loc: Republic of Moldova
In the following context taken from the mIRC help file:


You can use the ! prefix in front of variables and identifiers in an if-then-else statement to negate a value. The following statements are equivalent.

a) if (%x == $null) echo x has no value
b) if (!%x) echo x has no value

i can say it's false and let me explain why!

1. If %x doesn't exist, than the both points are true!
2. if you set %x to 0 than both a) and b) will not be equivalent, because %x is not null and ! negate the %x. The same if we set %x to $false.

Anyway, a) is different from b) smile

So, mIRC help file must be corrected smile

#261885 - 07/12/17 12:21 AM Re: Does mIRC help file doesn't contain mistakes? :) [Re: klez]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 869
It's not false. If %X is +4, it's referring to the value of (statement) being $true or $false, not multiplying the $true value of +4 by negative 1 and making it be -4, which is also a $true value. The ! is negating whether the "then" or "else" condition applies.

(statement) is $true, even if it's a negative number, unless it returns a value that's either $null or $false or something that evaluates to zero, including strings like +0 -0 or 0.00000. There's also a pair of doublequotes with nothing inside them that is also $false, but you can't put them into a %variable.

//var %x 0.00 | if (!%x) echo 4 if: v1 is $v1 and x is "not true": %x | else echo 2 else: v1 is $v1 and x is "true": %x