Difference between revisions of "$iif"

From Scriptwiki
Jump to: navigation, search
 
m
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:
  
  
$iif() returns F if the conditional returns zero, $false, or $null, else T.
+
$iif() returns F if the conditional returns zero, [[$false]], or [[$null]], else T.
  
 
If you don't specify the F parameter, $iif returns a T value if the condition is true, and returns nothing if it's false.
 
If you don't specify the F parameter, $iif returns a T value if the condition is true, and returns nothing if it's false.
  
 
== Example ==
 
== Example ==
  [[echo]] -a $iif($me == Dana, I am Dana, I am not Dana)
+
  [[echo]] -a $iif([[$me]] == Dana, I am Dana, I am not Dana)
 
This would probably echo ''I am not Dana'', as you don't have the nickname ''Dana''.
 
This would probably echo ''I am not Dana'', as you don't have the nickname ''Dana''.
  
  
  [[echo]] -a $iif($ignore,Ignoring is turned on,Ignoring is turned off)
+
  [[echo]] -a $iif([[$ignore]],Ignoring is turned on,Ignoring is turned off)
 
This would usually echo ''Ignoring is turned on'', as it's turned on by default.
 
This would usually echo ''Ignoring is turned on'', as it's turned on by default.
  
  
  [[echo]] -a $iif($active == #help.script && Dana ison $active,Dana is there, Dana isn't there)
+
  [[echo]] -a $iif([[$active]] == #help.script && Dana ison $active,Dana is there, Dana isn't there)
 
This would echo ''Dana is there'' if #help.script is your active window and Dana isin #help.script, else ''Dana isn't there''.
 
This would echo ''Dana is there'' if #help.script is your active window and Dana isin #help.script, else ''Dana isn't there''.
 +
 +
on *:text:!test:*:{ [[msg]] $iif($chan,$chan,$nick) testing }
 +
This event would trigger for channel and query text, and using $iif we can reply to $chan or $nick, depending on where it came from.
  
  
 
== See Also ==
 
== See Also ==
To learn more about if-then-else, take a look at [[If-then-else|this]] article.
+
* [[If-then-else]] to learn more about if-statements.
  
 
[[Category:Other Identifiers]]
 
[[Category:Other Identifiers]]

Latest revision as of 10:21, 2 July 2007

Returns T or F depending on whether the evaluation of the Conditional C is true or false.

$iif(C,T,F)

Note that you can use more comparisons too (see example below). To get more information about this, take a look at If-then-else.


$iif() returns F if the conditional returns zero, $false, or $null, else T.

If you don't specify the F parameter, $iif returns a T value if the condition is true, and returns nothing if it's false.

Example

echo -a $iif($me == Dana, I am Dana, I am not Dana)

This would probably echo I am not Dana, as you don't have the nickname Dana.


echo -a $iif($ignore,Ignoring is turned on,Ignoring is turned off)

This would usually echo Ignoring is turned on, as it's turned on by default.


echo -a $iif($active == #help.script && Dana ison $active,Dana is there, Dana isn't there)

This would echo Dana is there if #help.script is your active window and Dana isin #help.script, else Dana isn't there.

on *:text:!test:*:{ msg $iif($chan,$chan,$nick) testing }

This event would trigger for channel and query text, and using $iif we can reply to $chan or $nick, depending on where it came from.


See Also