Difference between revisions of "$iif"
(Added wiki links to page) |
|||
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''. | ||
Revision as of 04:51, 24 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.
See Also
To learn more about if-then-else, take a look at this article.