Difference between revisions of "Template:Val/delimitnum"

From blackwiki
Jump to navigation Jump to search
blackwiki>Cpiral
(Undid revision 671660547 by Cpiral (talk))
blackwiki>Cpiral
(Undid revision 671660652 by Cpiral (talk) fix)
Line 1: Line 1:
<includeonly>{{#ifeq: <!-- a sequence of three outputs equal to "04"? -->
+
<includeonly><!--
   {{#invoke:String|find|{{{1}}}|.}}<!-- Output a zero if no dot.
+
-->{{#ifeq: <!-- compare "04" to 4, and if so, output 4-digits pure
   -->{{#invoke:String|len <!-- Length of 4 with sign temporarily filtered? -->
+
  What might be "04" is composed of three outputs: dot, len, and fmt -->
     |{{#invoke:String|replace|{{{1}}}|[+-]|plain=false}}}}<!-- filter sign -->
+
   {{#invoke:String|find|{{{1}}}|.}}<!-- Output the zero if no dot.
  <!-- Any fmt given?  If so comparison to "4" will fail -->{{{fmt|}}}
+
   -->{{#invoke:String|len <!-- Length of 4 with sign and spaces filtered? -->
 +
     |{{#invoke:String|replace|{{{1}}}|[-+ ]|plain=false}}}}<!--  
 +
    That replace just filtered out any and all spaces, + or - characters.
 +
    But it's gotta have the minus sign first in the [-charclass].
 +
    Any fmt given?  If so comparison to "4" will fail -->{{{fmt|}}}
 
| 4 |{{#invoke:String|replace|{{{1}}}|-|&minus;}}<!--  
 
| 4 |{{#invoke:String|replace|{{{1}}}|-|&minus;}}<!--  
If fmt is nil, found . is 0, and len is 4, then 04=4,  
+
If fmt is nil, found . is 0, and filtered len is 4, then 04=4,  
and we just output the number, replacing any - with a minus sign
+
and we have just output the number, replacing any - with a minus sign
  
 
Else:  
 
Else:  

Revision as of 05:06, 16 July 2015

Template documentation[create]