Help:ParserFunctions

From Homestar Runner Wiki

Revision as of 22:49, 27 October 2007 by The Goblin (Talk | contribs)
Jump to: navigation, search
This page is created as a future help page, before it goes into the Help namespace. If you have any ideas for this page, please tell me on the talk page.

This wiki has an extension installed, called ParserFunctions. Here's how to use them:

#expr:

expr solves mathematical expressions. It does not work with strings, if you want to use those, see ifeq.

Operator Operation Example
() Grouping operators {{#expr: (10+20) / 30 }} = 0
+ Positive {{#expr: +30 - +30 }} = 0
- Negative {{#expr: -30 + 30 }} = 0
not Unary NOT, logical NOT {{#expr: not 30 + 0}} = 0
* Multiplication {{#expr: 30 * 0 }} = 0
/ OR div Division {{#expr: -30 / 30 }} = -1
{{#expr: -30 div 30 }} = -1
+ Addition {{#expr: -30 + 30 }} = 0
- Subtraction {{#expr: 30 - 30 }} = 0
round Rounds off the number on the left to the power of 1/10 given on the right {{#expr: 24 / 49 round 4}} = 0.4898
{{#expr: 24 / 49 round 2}} = 0.49
{{#expr: 24 / 49 round 0}} = 0
= Equality (will be 1 or 0) {{#expr: 30 = 0 }} = 0
{{#expr: 30 = 30 }} = 1
<> OR  != Inequality (will be 1 or 0) {{#expr: 30 <> 0 }} = 1
{{#expr: 30 <> 30 }} = 0
{{#expr: 30 != 0 }} = 1
{{#expr: 30 != 30 }} = 0
< Less Than (will be 1 or 0) {{#expr: 30 < 0 }} = 0
> Greater Than (will be 1 or 0) {{#expr: 30 > 0 }} = 1
>= Greater Than or Equal To (will be 1 or 0) {{#expr: 30 >= 0 }} = 1
<= Less Than or Equal To (will be 1 or 0) {{#expr: 30 <= 0 }} = 0

#if:

The if function is an if-then-else system. It measures if the condition string is empty, it does the else text. If it is not empty, it does the than text. The syntax is:

{{#if: <condition string> | <then text> | <else text> }}

Its most common usage is in templates, where if the user defines a parameter, then it shows this text. If the user does not specify it, it shows a default. Example:

{{#if: {{{parameter|}}} | Parameter is defined | Parameter is not defined }}

If the user types {{templatename|parameter=true}} or somethign similar, the result is "Parameter is defined". However, if they type {{templatename}}, the result it "Parameter is not defined".

This does not solve expressions. For example, if you type {{#if: 30 - 30 = 50 | 1 | 0 }}, the result will be 1, since 30 - 30 = 50 is not empty.

Personal tools