mIRC Home    About    Download    Register    News    Help

Print Thread
#232555 09/06/11 11:41 AM
Joined: Apr 2011
Posts: 14
O
Onions Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Apr 2011
Posts: 14
//echo -a $iif(0,1,2)

Why does that return 2?

Onions #232557 09/06/11 11:46 AM
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
It's not a bug, $null $false and 0 are considered the same in a condition.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Onions #232559 09/06/11 01:51 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
In addition, if you need a check that treats 0 as a number, then you will want to use a standard comparison (checking if something isnum or > or < or == to something).

As an example:
//echo -a $iif(0 isnum 0-5,1,2)

You can also check specifically for $null or $false...
//echo -a $iif(0 != $null,1,2)
//echo -a $iif(0 != $false,1,2)

Last edited by Riamus2; 09/06/11 01:54 PM.

Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard