mIRC Home    About    Download    Register    News    Help

Print Thread
#147263 16/04/06 07:36 PM
Joined: Aug 2005
Posts: 128
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
In the page "if then else" on mirc's helpfile it says:
Code:
The ! not prefix
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.

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

if (!%x) echo x has no value

which is wrong, this is not a major problem, but should be fixed in next version, since it might get some people confused.

#147264 16/04/06 08:17 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
How are you determining that those two lines are not the same? I've used this option (ie: using !%var rather than %var == $null) many times, and I have yet to see it fail.

#147265 16/04/06 08:27 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
if (%x == $null) will only be $true when %x is $null.
if (!%x) will be $true if %x is 0, $false or $null

Fairly big difference.

#147266 16/04/06 08:28 PM
Joined: Feb 2005
Posts: 681
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2005
Posts: 681
if (!%x) would be true if %x were $false or $null or 0 or 0000000 ... any negative value or no value at all.

if (%x == $null) would only be true if %x has no value at all.

~ Edit ~

hixxy beat me to it smile

Last edited by mIRCManiac; 16/04/06 08:28 PM.
#147267 16/04/06 09:34 PM
Joined: Aug 2005
Posts: 128
S
Vogon poet
OP Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
Quote:
if (!%x) would be true if %x were $false or $null or 0 or 0000000 ... any negative value or no value at all.

if (%x == $null) would only be true if %x has no value at all.

~ Edit ~

hixxy beat me to it smile

not true for negative values (only $false, 000...000, $null)

Last edited by stefys99; 16/04/06 09:36 PM.
#147268 16/04/06 11:39 PM
Joined: Feb 2005
Posts: 681
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2005
Posts: 681
Your examples are the same negative values I (and hixxy) gave.
And I did mean negative value for %x not negative number.
-1 is a negative number but would not be a negative value for %x

Last edited by mIRCManiac; 16/04/06 11:41 PM.

Link Copied to Clipboard