5,594
edits
(→Advanced Template Usage: #ifeq documentation) |
|||
Line 247: | Line 247: | ||
| | | | ||
<nowiki>{{#expr: 4<5 or 4 mod 2}}</nowiki> = {{#expr: 4<5 or 4 mod 2}} | <nowiki>{{#expr: 4<5 or 4 mod 2}}</nowiki> = {{#expr: 4<5 or 4 mod 2}} | ||
|} | |||
===<nowiki>{{#ifeq:}}</nowiki>=== | |||
This function compares a string or numerical value in <parameter to test> to the string or numerical value in <parameter to compare test to>. If you wish to compare strings represented by numbers and numeral operators, enclose the string within "" to force a string comparison. <What to display if test is true> and <what to display if test is false> are optional, but one must be used unless you wish to return absolutely nothing. Also, when testing operations, use <nowiki>{{#expr:}}</nowiki>. The usage for <nowiki>{{#ifeq:}}</nowiki> is as follows: | |||
<pre>{{#ifeq:<parameter to test> | |||
|<parameter to compare test to> | |||
|<what to display if test is true> | |||
|<what to display if test is false>}}</pre> | |||
{| {{prettytable}} | |||
|bgcolor="#A7C1F2" colspan="2" align="center"|'''Usage of <nowiki>{{#ifeq:}}</nowiki>''' | |||
|- | |||
!What you type | |||
!What is displayed | |||
|- | |||
|<pre>{{#ifeq:+07|007|yes|no}}</pre> | |||
|{{#ifeq:+07|007|yes|no}} | |||
|- | |||
|<pre>{{#ifeq:"+07"|"007"|yes|no}}</pre> | |||
|{{#ifeq:"+07"|"007"|yes|no}} | |||
|- | |||
|<pre>{{#ifeq:foo|bar|yes|no}}</pre> | |||
|{{#ifeq:foo|bar|yes|no}} | |||
|- | |||
|<pre>{{#ifeq:{{#expr:7*5+5}}|40|yes|no}}</pre> | |||
|{{#ifeq:{{#expr:7*5+5}}|40|yes|no}} | |||
|} | |} | ||