Template:Val: Difference between revisions
From Zoophilia Wiki
Jump to navigationJump to search
meta>Quondum whoops: </noinclude> → <noinclude> |
meta>Cpiral Remove recently added noinclude tags to restore readability. |
||
| Line 1: | Line 1: | ||
<includeonly | <includeonly><!-- | ||
-- | --><span class="nowrap"><!-- | ||
START ERROR CHECKING: | START ERROR CHECKING: | ||
-- | -->{{#iferror:{{#expr:{{{1|0}}}}}<!-- Is arg1 not a valid number? | ||
arg1 isn't valid -- | arg1 isn't valid -->|{{FormattingError|Error in {{tl|val}}: first argument is not a valid number.|nocategory={{{nocategory|}}}}}<!-- | ||
arg1 is valid -- | arg1 is valid -->|{{#iferror:{{#expr:{{{2|0}}}}}<!-- Is arg2 not a valid number? | ||
arg2 isn't valid -- | arg2 isn't valid -->|{{FormattingError|Error in {{tl|val}}: second argument is not a valid number.|nocategory={{{nocategory|}}}}}<!-- | ||
arg2 is valid -- | arg2 is valid -->|{{#iferror:{{#expr:{{{3|0}}}}}<!-- Is arg3 not a valid number? | ||
arg3 isn't valid -- | arg3 isn't valid -->|{{FormattingError|Error in {{tl|val}}: third argument is not a valid number.|nocategory={{{nocategory|}}}}}<!-- | ||
arg3 is valid -- | arg3 is valid -->|{{#ifexpr: {{{2|0}}} < 0<!-- Is arg2 negative? | ||
arg2 is negative -- | arg2 is negative -->|{{FormattingError|Error in {{tl|val}}: second argument is negative.|nocategory={{{nocategory|}}}}}<!-- | ||
arg2 is positive -- | arg2 is positive -->|{{#iferror:{{#expr:{{{e|0}}}}}<!-- Is arg "e" not a valid number? | ||
"e" isn't valid -- | "e" isn't valid -->|{{FormattingError|Error in {{tl|val}}: exponent ('''e''') is not a valid number.|nocategory={{{nocategory|}}}}}<!-- | ||
"e" is valid -- | "e" is valid -->|{{#ifeq:{{{u}}}{{{ul}}}|{{{u|}}}{{{ul|}}}<!-- Is arg "u" and "ul" specified? | ||
"u" & "ul" both specified -- | "u" & "ul" both specified -->|{{FormattingError|Error in {{tl|val}}: unit ('''u''') and units with link ('''ul''') are both specified, only one is allowed.|nocategory={{{nocategory|}}}}}<!-- | ||
"u" & "ul" not both specified -- | "u" & "ul" not both specified -->|{{#ifeq:{{{up}}}{{{upl}}}|{{{up|}}}{{{upl|}}}<!-- Is arg "up" and "upl" specified? | ||
"up" & "ulp" both specified -- | "up" & "ulp" both specified -->|{{FormattingError|Error in {{tl|val}}: unit per ('''up''') and units per with link ('''upl''') are both specified, only one is allowed.|nocategory={{{nocategory|}}}}}<!-- | ||
"up" & "ulp" not both specified -- | "up" & "ulp" not both specified -->|<!-- | ||
END OPENING OF ERROR CHECKING, START OUTPUT | END OPENING OF ERROR CHECKING, START OUTPUT | ||
START HIDDEN SORT KEY | START HIDDEN SORT KEY | ||
-- | -->{{#ifeq:{{{sortable}}}|off||{{val/sortkey|{{{sortval|{{{1|1}}}}}}|e={{{e|0}}}|u={{{us|{{{u|{{{ul|}}}}}}}}}|up={{{ups|{{{up|{{{upl|}}}}}}}}}|ls={{{long scale}}}}}}}<!-- hidden sort key based on the SI base unit(s) | ||
END HIDDEN SORT KEY | END HIDDEN SORT KEY | ||
START PREFIX | START PREFIX | ||
-- | -->{{{p|}}}<!-- If p (prefix) is defined, display it. | ||
END PREFIX | END PREFIX | ||
START NUMERICAL OUTPUT | START NUMERICAL OUTPUT | ||
<!-- numerical output -->{{#if:{{{1|}}}<!-- Are there any arguments? | |||
There are arguments. -- | There are arguments. -->|{{#if:{{{2|}}}<!-- Are there 2 or more arguments? | ||
There are 2 or more arguments. -- | There are 2 or more arguments. -->|{{#if:{{{3|}}}<!-- Are there 3 arguments? | ||
There are 3 arguments. -- | There are 3 arguments. -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted. | ||
-- | -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!-- Append something and/or add angle/percent symbol. | ||
Uncertainty = +X/-Y -- | Uncertainty = +X/-Y -->{{val/+-<!-- Add + & - errors. | ||
-- | -->|w={{{w|}}}|a={{{a|r}}}<!-- Option fixed width, default right aligned | ||
-- | -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}|nosign=on}}<!-- Output +arg2, formatted. | ||
-- | -->{{{+errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!-- Append something and/or add angle/percent symbol. | ||
-- | -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{3}}}|nosign=on}}<!-- Output -arg3, formatted. | ||
-- | -->{{{-errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!-- Append something and/or add angle/percent symbol. | ||
-- | -->}}<!-- End are there 3 arguments (Uncertainty = +X/-Y) | ||
-- | -->{{#if:{{{e|}}}<!-- Is there an exponent? | ||
There is an exponent. -- | There is an exponent. -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e | ||
-- | -->}}<!-- End is there an exponent | ||
There are there not three arguments. -- | There are there not three arguments. -->|{{#iferror:{{#expr:0{{{2}}}}}<!-- Is second argument "(number)"? | ||
Second argument is "(number)". -- | Second argument is "(number)". -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted. | ||
-- | -->{{{end|}}}{{{2}}}<!-- Uncertainty (X) | ||
-- | -->{{val/angle|{{{u}}}|{{{ul}}}}}<!-- Add angle/percent symbol. | ||
-- | -->{{#if:{{{e|}}}<!-- Is there an exponent? | ||
-- | -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e | ||
-- | -->}}<!-- End is there an exponent | ||
Second argument is not "(number)".-- | Second argument is not "(number)".-->|{{#if:{{{e|}}}<!-- Is there an exponent? | ||
There is an exponent. -- | There is an exponent. -->|({{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted. | ||
-- | -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!-- Append something and/or add angle/percent symbol. | ||
Uncertainty = ±X -- | Uncertainty = ±X -->{{val/±<!-- Add ± symbol. | ||
-- | -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<!-- Format number. | ||
-- | -->{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!-- Append something and/or add angle/percent symbol. | ||
-- | -->}})<!-- End Uncertainty = ±X | ||
-- | --><span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e | ||
There is no exponent. -- | There is no exponent. -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted. | ||
-- | -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!-- Append something and/or add angle/percent symbol. | ||
Uncertainty = ±X -- | Uncertainty = ±X -->{{val/±<!-- Add ± symbol. | ||
-- | -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<!-- Format number. | ||
-- | -->{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!-- Append something and/or add angle/percent symbol. | ||
-- | -->}}<!-- End Uncertainty = ±X | ||
-- | -->}}<!-- End is there and exponent. | ||
-- | -->}}<!-- End second argument is "(number)"? | ||
-- | -->}}<!-- End Are there 3 arguments? | ||
2 arguments? No -- | 2 arguments? No -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted. | ||
-- | -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!-- Append something and/or add angle/percent symbol. | ||
-- | -->{{#if:{{{e|}}}<!-- Is there an exponent? | ||
There is an exponent. -- | There is an exponent. -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e | ||
-- | -->}}<!-- End is there an exponent | ||
-- | -->}}<!-- End Are there 2 or more arguments? | ||
There are no arguments. -- | There are no arguments. -->|10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e|0}}}}}</sup><!-- Output 10^e only. | ||
-- | -->}}<!-- End Are there any arguments? | ||
END NUMERICAL OUTPUT | END NUMERICAL OUTPUT | ||
START UNITS | START UNITS | ||
-- | -->{{#if:{{{up|}}}{{{upl|}}} | ||
| | |||
{{#if:{{{u|}}} | |||
| | |||
{{#ifexpr:{{#invoke:String|find|source={{{u}}}|target=[./*]|plain=false}} | |||
| | |||
{{#invoke:String|replace | |||
|source = | |||
{{#invoke:String|replace | |||
<!-- [[title|markup]]: & (or [) is 1st, [ is 7th (or 1st)--> | <!-- [[title|markup]]: & (or [) is 1st, [ is 7th (or 1st)--> | ||
|source = {{Val/units|{{{u}}}}} | |||
|pattern = %[%[.+{{!}} <!--keeps , but compare others --> | |||
|replace = ( | |||
|plain = false | |||
}} | |||
|pattern = ]] | |||
|replace = ) | |||
}} | |||
| <!-- Same thing, but without replace with parentheses --> | |||
{{#invoke:String|replace | |||
|source = | |||
{{#invoke:String|replace | |||
|source = {{Val/units|{{{u}}}}} | |||
|pattern = %[%[.+{{!}} | |||
|replace = | |||
|plain = false | |||
}} | |||
|pattern = ]] | |||
|replace = | |||
}} | |||
}} | |||
}}<!-- end up/upl AND u | |||
-- | -->{{#if:{{{ul|}}} <!-- With up/upl its possible to have neither u nor ul.--> | ||
| | |||
{{#ifexpr:{{#invoke:String|find|source={{{ul}}}|target=[./*]|plain=false}} | |||
| <!-- Grouping parentheses --> | |||
{{#invoke:String|replace | |||
|source = | |||
{{#invoke:String|replace | |||
|source = {{Val/units|{{{ul}}}|ls={{{long scale}}}}} | |||
|pattern = [ <!-- keep spacing --> | |||
|replace = ([ | |||
|count = 1 | |||
}} | |||
|pattern = %]%] | |||
|replace = ]]) | |||
|plain = false <!-- using %]%], not ]], prevents code mangle --> | |||
}} | |||
| <!-- normal call --> | |||
{{val/units|{{{ul}}}|ls = {{{long scale}}}}} | |||
}} | |||
}}<!-- End up/upl AND ul | |||
-- | -->{{#if:{{{up|}}} | ||
| | | | ||
{{#ifexpr:{{#invoke:String|find|source={{{up}}}|target=[./*]|plain=false}} | {{#ifexpr:{{#invoke:String|find|source={{{up}}}|target=[./*]|plain=false}} | ||
| Line 137: | Line 137: | ||
|source = | |source = | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source={{Val/units | |source = {{Val/units|{{{up}}}}} | ||
|pattern=.*%[%[.+{{!}} | |pattern = .*%[%[.+{{!}} <!-- remove spacing --> | ||
|replace=/( | |replace = /( | ||
|plain=false | |plain = false | ||
}} | }} | ||
|pattern=]] | |pattern = ]] | ||
|replace=) | |replace = ) | ||
}} | }} | ||
| | | <!-- Same thing, but without replace with parentheses --> | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source= | |source = | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source={{Val/units | |source = {{Val/units|{{{up}}}}} | ||
|pattern=.*%[%[.+{{!}} | |pattern = .*%[%[.+{{!}} | ||
|replace=/ | |replace = / | ||
|plain=false | |plain = false | ||
}} | }} | ||
|pattern=]] | |pattern = ]] | ||
|replace= | |replace = | ||
}} | }} | ||
}} | }} | ||
| | | <!-- upl --> | ||
{{#ifexpr:{{#invoke:String|find|source={{{upl}}}|target=[./*]|plain=false}} | |||
| | | | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source= | |source = | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source={{Val/units | |source = {{Val/units|{{{upl}}}}} | ||
|pattern=.-%[ | |pattern = .-%[ <!-- remove spacing --> | ||
|replace=/([ | |replace = /([ | ||
|plain=false | |plain = false | ||
|count=1 | |count = 1 | ||
}} | }} | ||
|pattern=%]%] | |pattern = %]%] | ||
|replace=]]) | |replace = ]]) | ||
|plain=false | |plain = false | ||
}} | }} | ||
| | | <!-- Same thing, but without replace with parentheses --> | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source={{val/units | |source = {{val/units|{{{upl}}}}} | ||
|pattern=.-%[ | |pattern = .-%[ <!-- remove spacing: PCRE is .*?[ --> | ||
|replace=/[ | |replace = /[ | ||
|plain=false | |plain = false | ||
|count=1 | |count = 1 | ||
}} | }} | ||
}} | }} | ||
}} | }} | ||
| | | <!-- No up/upl --> | ||
{{#if:{{{u|}}} | {{#if:{{{u|}}} | ||
| | | | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source= | |source = | ||
{{#invoke:String|replace | {{#invoke:String|replace | ||
|source={{val/units | |source = {{val/units|{{{u}}}}} | ||
|pattern=%[%[.+{{!}} | |pattern = %[%[.+{{!}} <!-- keep unit spacing --> | ||
|replace= | |replace = | ||
|plain=false | |plain = false | ||
}} | }} | ||
|pattern=]] | |pattern = ]] | ||
|replace= | |replace = | ||
}} | }} | ||
}} | }}<!-- | ||
-- | -->{{#if:{{{ul|}}} | ||
|{{val/units | |{{val/units|{{{ul}}}|ls = {{{long scale}}}}} | ||
}} | }} | ||
}} | }}<!-- end up/upl | ||
END UNITS | END UNITS | ||
START SUFFIX | START SUFFIX | ||
-- | -->{{{s|}}}<!-- If s (suffix) is defined, display it. | ||
END PREFIX | END PREFIX | ||
START CLOSING OF ERROR CHECKING | START CLOSING OF ERROR CHECKING | ||
-- | -->}}<!-- End Is arg "up" and "upl" specified? | ||
-- | -->}}<!-- End Is arg "u" and "ul" specified? | ||
-- | -->}}<!-- End Is arg "e" not a valid number? | ||
-- | -->}}<!-- End Is arg2 negative? | ||
-- | -->}}<!-- End Is arg3 not a valid number? | ||
-- | -->}}<!-- End Is arg2 not a valid number? | ||
-- | -->}}<!-- End Is arg1 not a valid number? | ||
END ERROR CHECKING | END ERROR CHECKING | ||
-- | --></span></includeonly><noinclude> | ||
{{documentation}} | {{documentation}} | ||
</noinclude> | </noinclude> | ||
Revision as of 23:53, 4 June 2015
Lua error in Module:Documentation at line 7: Module:Documentation/config returned boolean, table expected.