Template:Val/delimitnum: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Cpiral
4-digit pure, and no fmt=commas4, and no concern with units
meta>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