mIRC Home    About    Download    Register    News    Help

Print Thread
#234478 27/10/11 12:57 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
if (%var) { do stuff }
this should trigger if the %var exist. And it do so with value 1, but if the value is set to 0 then it will not trigger, since it exist with the value 0 it should trigger.

mirc version
7.19 and 7.22


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #234479 27/10/11 12:59 PM
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
This isn't a bug, if (condition) is true if 'condition' is different than 0, $false and $null


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
sparta #234487 27/10/11 04:02 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As Wims explained, an IF looks to see if something is true or not. Not true includes the three things mentioned (0, $null, $false). If you need it to treat a 0 as true, then you need to be more specific in your IF....

For example:
Code:
if (%var != $null) { }


*Note that the above example would also be true for $false, so depending on what %var could be, you may also need to include an OR to check if it's != $false as well.


Invision Support
#Invision on irc.irchighway.net
Riamus2 #234489 27/10/11 08:01 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
i noticed that, so made a alias that check the %var. Ty


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Link Copied to Clipboard