User:Closeapple/examples/digital
Appearance
{{#ifeq:{{{digits}}}|0|STNODIGITS{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:(ln {{{1|0}}}/ln 10)+1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDNODIGITS|STDIGITS[[File:{{#ifexpr:trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}|{{{style|Seven segment display_}}}{{#expr:(trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}) mod 10}}{{{suffix|_digit_(red).svg}}}|1x1.png}}{{subst1}}!}}{{{size|25px}}}]]{{#ifexpr:{{{digits}}}-1|{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:{{{digits}}}-1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDDIGITS}}
This template is an example of parsing numbers using recursion.
Use
[edit]Number can be any positive number, probably 10 digits or less.
Basic
[edit]- {{User:Closeapple/examples/digital|number}}
- {{User:Closeapple/examples/digital|number|digits=digits}}
Optional parameters
[edit]- size=sizepx to override default 25px
- style=prefix to override default Seven segment display_
- suffix=suffix to override default _digit (red).svg
Examples
[edit]{{User:Closeapple/examples/digital|9}} | {{#ifeq:{{{digits}}}|0|STNODIGITS{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:(ln {{{1|0}}}/ln 10)+1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDNODIGITS|STDIGITS[[File:{{#ifexpr:trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}|{{{style|Seven segment display_}}}{{#expr:(trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}) mod 10}}{{{suffix|_digit_(red).svg}}}|1x1.png}}{{subst1}}!}}{{{size|25px}}}]]{{#ifexpr:{{{digits}}}-1|{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:{{{digits}}}-1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDDIGITS}} |
{{User:Closeapple/examples/digital|9|digits=5}} | {{#ifeq:{{{digits}}}|0|STNODIGITS{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:(ln {{{1|0}}}/ln 10)+1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDNODIGITS|STDIGITS[[File:{{#ifexpr:trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}|{{{style|Seven segment display_}}}{{#expr:(trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}) mod 10}}{{{suffix|_digit_(red).svg}}}|1x1.png}}{{subst1}}!}}{{{size|25px}}}]]{{#ifexpr:{{{digits}}}-1|{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:{{{digits}}}-1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDDIGITS}} |
{{User:Closeapple/examples/digital|123}} | {{#ifeq:{{{digits}}}|0|STNODIGITS{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:(ln {{{1|0}}}/ln 10)+1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDNODIGITS|STDIGITS[[File:{{#ifexpr:trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}|{{{style|Seven segment display_}}}{{#expr:(trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}) mod 10}}{{{suffix|_digit_(red).svg}}}|1x1.png}}{{subst1}}!}}{{{size|25px}}}]]{{#ifexpr:{{{digits}}}-1|{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:{{{digits}}}-1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDDIGITS}} |
{{User:Closeapple/examples/digital|123|digits=5}} | {{#ifeq:{{{digits}}}|0|STNODIGITS{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:(ln {{{1|0}}}/ln 10)+1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDNODIGITS|STDIGITS[[File:{{#ifexpr:trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}|{{{style|Seven segment display_}}}{{#expr:(trunc abs {{{1|0}}} div 1E{{#expr:{{{digits}}}-1}}) mod 10}}{{{suffix|_digit_(red).svg}}}|1x1.png}}{{subst1}}!}}{{{size|25px}}}]]{{#ifexpr:{{{digits}}}-1|{{<includeonly></includeonly>subst:subst1}}User:Closeapple/examples/digital{{<includeonly></includeonly>subst:!}}digits={{#eval:{{{digits}}}-1}}{{<includeonly></includeonly>subst:!}}style={{{style|}}}{{<includeonly></includeonly>subst:!}}suffix={{{suffix|}}}{{<includeonly></includeonly>subst:!}}size={{{size|}}}{{<includeonly></includeonly>subst:!}}1={{{1}}}{{<includeonly></includeonly>subst:rb}}ENDDIGITS}} |