$iif: Difference between revisions

From Scriptwiki
Jump to navigation Jump to search
Added wiki links to page
m changed "see also", and added $iif($chan,$chan,$nick) example
Line 20: Line 20:
  [[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.
* To learn more about if-then-else, take a look at [[If-then-else|this]] article.
 
[[Category:Other Identifiers]]
[[Category:Other Identifiers]]

Revision as of 07:27, 29 June 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

  • To learn more about if-then-else, take a look at this article.