Difference between revisions of "Template:Val/delimitnum"

From blackwiki
Jump to navigation Jump to search
blackwiki>Cpiral
(4-digit pure, and no fmt=commas4, and no concern with units)
blackwiki>Cpiral
(accept signed 4-digits as pure 4-digits)
Line 1: Line 1:
<includeonly>{{#ifeq:  
+
<includeonly>{{#ifeq: <!-- a sequence of three outputs equal to "04"? -->
{{#invoke:String|find|{{{1}}}|[+-.]|plain=false}}{{#invoke:String|len|{{{1}}}}}{{{fmt|}}}
+
  {{#invoke:String|find|{{{1}}}|.}}<!-- Output a zero if no dot.
| 4 |{{{1}}}<!-- if fmt is nil,found +=. is 0, len is 4,  
+
  -->{{#invoke:String|len <!-- Length of 4 with sign temporarily filtered? -->
then 04=4, output the number, else:  
+
    |{{#invoke:String|replace|{{{1}}}|[+-]|plain=false}}}}<!-- filter sign -->
 +
  <!-- Any fmt given?  If so comparison to "4" will fail -->{{{fmt|}}}
 +
| 4 |{{{1}}}<!--  
 +
If fmt is nil, found . is 0, and len is 4, then 04=4,  
 +
and we just output the number.
 +
 
 +
Else:  
 
-->|{{#switch: <!-- its not a pure 4-digit number with no fmt options given-->
 
-->|{{#switch: <!-- its not a pure 4-digit number with no fmt options given-->
 
{{#invoke:String|sub|{{{1|0}}}|1|1}}
 
{{#invoke:String|sub|{{{1|0}}}|1|1}}

Revision as of 00:10, 19 June 2015

50px Template documentation[create]