Difference between revisions of "Module:Range/doc"

From blackwiki
Jump to navigation Jump to search
blackwiki>קיפודנחש
(Created page with 'returns one function called "iswitch", which takes its inspiration from <nowiki>{{#switch</nowiki>, but is limited to numeric values, and allows for ranges. usa...')
 
blackwiki>קיפודנחש
(ident)
Line 4: Line 4:
  
 
  <nowiki>{{#invoke|Range|inrange
 
  <nowiki>{{#invoke|Range|inrange
|12
+
| 12
|1 2 3..7 50..70 = one, two, three to seven, or fifty to seventy
+
| 1 2 3..7 50..70 = one, two, three to seven, or fifty to seventy
 
| 9..40 = between nine and fourty  
 
| 9..40 = between nine and fourty  
|default = None of the ranges matches 12
+
| default = None of the ranges matches 12
 
}}</nowiki>
 
}}</nowiki>
  

Revision as of 05:00, 14 March 2013

returns one function called "iswitch", which takes its inspiration from {{#switch, but is limited to numeric values, and allows for ranges.

usage:

{{#invoke|Range|inrange
| 12
| 1 2 3..7 50..70 = one, two, three to seven, or fifty to seventy
| 9..40 = between nine and fourty 
| default = None of the ranges matches 12
}}

syntax: {{#invoke:Range | iswitch | <Number> | (<Range> = Value | )... [default=Value] }}

<Number> ::= [-][digits][.][digits][e digits]
<Range> ::= [<Number> | <Number>..<Number>]...
Value ::= any string that does not contain | or }}

if the first parameter matches a ranges, function will return the values of one of the matching ranges. If more than one range matches, it is unpredictable which of the values will be returned.

if none of the ranges match, and there is a "default", this value will return. otherwise, the function will return an empty string.