From WikiChip
Editing mirc/identifiers/$iif

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 5: Line 5:
 
== Parameters ==
 
== Parameters ==
 
* '''C''' - A conditional statement that determines whether this identifier returns the $true or $false conditional.
 
* '''C''' - A conditional statement that determines whether this identifier returns the $true or $false conditional.
* '''T''' - The string returned and/or identifier evaluated/executed if the C statement is $true
+
* '''T''' - The string returned and/or identifier executed if the C statement is $true
* '''F''' - Optional string returned and/or identifier evaluated/executed if the C statement is $false
+
* '''F''' - Optional string returned and/or identifier executed if the C statement is $false
  
 
Note: If F parameter is not used, $iif returns $null if the C statement is $false<br />
 
Note: If F parameter is not used, $iif returns $null if the C statement is $false<br />
Note: If C evaluates to $false or $null or 0 (including 000 or 0.00), it is $false. $true or non-zero or text strings are $true<br />
+
Note: If C evaluates to $false or $null or 0 (including 000 or 0.00), it is $false, $true or non-zero or text strings are $true
Note: If both T and F conditions contain identifier calls, the T condition's identifier/alias is called/evaluated only if C evaluates as $true, and the F condition's alias is called only if C evaluates as $false
 
 
== Properties ==
 
== Properties ==
 
None
 
None
  
 
== Example ==
 
== Example ==
<source lang="mIRC">
 
//echo -a My IP address $ip is an $iif( $calc($right($ip,1) % 2),odd,even) number
 
</source>
 
 
<source lang="mIRC">
 
<source lang="mIRC">
 
//echo -a $iif(0,$custom1(true1),$custom2(false2)) / $v1 $v2
 
//echo -a $iif(0,$custom1(true1),$custom2(false2)) / $v1 $v2
 
+
= calls the custom2 identifier and returns any string returned by it. $v1 is filled with the 1st term of the C condition.
Calls the custom2 identifier and returns any string returned by it.
 
$v1 is filled with the 1st term of the C condition. Because the conditional was $false, the $custom1 alias in the T branch is not called.
 
 
 
 
//echo -a $iif(2 > 1,$custom1(true1),$custom2(false2)) / $v1 $v2
 
//echo -a $iif(2 > 1,$custom1(true1),$custom2(false2)) / $v1 $v2
 
+
= calls the custom1 identifier and returns any string returned by it. $v1 is filled with 2 (the 1st term of the C condition) and $v2 is filled with 1 (the 2nd term of C).
Calls the custom1 identifier and returns any string returned by it.
+
//echo -a echo -a today: $iif($asctime($ctime,ddd) isin MonTueWedThuSat,Weekday,Weekend)
$v1 is filled with 2 (the 1st term of the C condition) and $v2 is filled with 1 (the 2nd term of C).
+
//echo -a echo -a today: $iif($asctime($ctime,ddd) isin MonTueWedThuSat,Weekday)
 
 
//echo -a today: $iif($asctime($ctime,ddd) isin MonTueWedThuFri,Weekday,Weekend)
 
//echo -a today: $iif($asctime($ctime,ddd) isin MonTueWedThuFri,Weekday)
 
 
   1st of the pair returns either Weekday or Weekend
 
   1st of the pair returns either Weekday or Weekend
 
   2nd of the pair returns either Weekday or $null because of the missing F parameter.
 
   2nd of the pair returns either Weekday or $null because of the missing F parameter.
 
 
   $iif conditionals can be nested:
 
   $iif conditionals can be nested:
 
//echo -a Classes on the $iif($asctime($ctime,ddd) isin SatSun,Sat-Sun, $iif(T* iswm $asctime($ctime,ddd),Tue-Thur,Mon-Wed-Fri)) Schedule meet today
 
//echo -a Classes on the $iif($asctime($ctime,ddd) isin SatSun,Sat-Sun, $iif(T* iswm $asctime($ctime,ddd),Tue-Thur,Mon-Wed-Fri)) Schedule meet today
 
</source>
 
</source>
 
Note: see the {{mIRC|msl_injection}} page for explanation/examples of how malformed $iif syntax can trick users into executing code from the editbox. This next example causes you to perform the /QUIT command if you remove the 'echo -a' from it:
 
 
<source lang="mIRC">
 
//echo -a $iif(($regsubex(dim[int:x];for[x=0:20:3]x*TAN-1<<DEG[]<<SQ[],/[^A1NT]/g,)) echo -a $base($v1, 34, 35) I accidentally math, I math right! )
 
</source>
 
 
Note: $iif is a relatively slow identifier, and in some situations it can benchmark faster to replace it with a /set and an /if command pair.
 
 
<source lang="mIRC">
 
//var %a $iif($rand(0,1),True,False)
 
vs
 
var %a False
 
if ($rand(0,1)) var %a True
 
</source>
 
 
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|5.4}}
 
{{mIRC compatibility|5.4}}
 +
 
== See Also ==
 
== See Also ==
 
{{collist
 
{{collist
Line 63: Line 37:
 
* {{mIRC|$true}}
 
* {{mIRC|$true}}
 
* {{mIRC|$false}}
 
* {{mIRC|$false}}
* {{mIRC|msl_injection}}
 
 
}}
 
}}
 
[[Category:mIRC identifiers|$didtok]]
 
[[Category:mIRC identifiers|$didtok]]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)