mIRC Home    About    Download    Register    News    Help

Print Thread
Does mIRC help file doesn't contain mistakes? :) #261883 06/12/17 08:57 PM
Joined: Sep 2015
Posts: 85
klez Offline OP
Babel fish
OP Offline
Babel fish
Joined: Sep 2015
Posts: 85
In the following context taken from the mIRC help file:

Quote:

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

Re: Does mIRC help file doesn't contain mistakes? :) [Re: klez] #261885 07/12/17 12:21 AM
Joined: Jan 2004
Posts: 1,201
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,201
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.

Quote:
//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