User talk:Johan G/convert: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(does template add trailing units to results? also only get red "value missing" error)
 
(→‎Architectural ideas: Some ideas to make the template a bit less of a monstrosity to develop, expand and maintain)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Parameter value missing ==
does this template automatically add the to-unit units? in other words, if i "convert|100|mph|kts" will it put kts after the converted number?
does this template automatically add the to-unit units? in other words, if i "convert|100|mph|kts" will it put kts after the converted number?


Line 4: Line 5:


--[[User:Wkitty42|Wkitty42]] ([[User talk:Wkitty42|talk]]) 10:58, 4 August 2018 (EDT)
--[[User:Wkitty42|Wkitty42]] ([[User talk:Wkitty42|talk]]) 10:58, 4 August 2018 (EDT)
: Hmm. Looking at the template I nearly immediately spotted the problem.  I had used named parameters instead of unnamed/numbered parameters (i.e. using <code><nowiki>{{{value}}}</nowiki></code> in the template, requiring the value to be written as <code><nowiki>value=72</nowiki></code> when "calling" the template instead of just <code><nowiki>72</nowiki></code> as was intended).
: With that fixed the issue should be limited to "just" units not yet implemented. :-P
: —[[User:Johan G|Johan G]] ([[User_talk:Johan_G|Talk]] | [[Special:Contributions/Johan_G|contribs]]) 13:19, 5 August 2018 (EDT)
:: yes! it is working great! there are some tricks, though...
* when using the template, you '''must''' have 5 |'s in the parameters.
* if the exprn has round in it, you have to put a value, even zero, in the decimals field.
* the hide field is the only field that can be empty.
* when editing the template's #exprns, multiplying is done with *
* there is / and div for division. i think one is for integers and the other for whole numbers like in some programming languages
* see here for operands that can be used in #exprns - https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions##expr
:: --[[User:Wkitty42|Wkitty42]] ([[User talk:Wkitty42|talk]]) 14:12, 5 August 2018 (EDT)
i forgot to add, check out my sandbox play with this template [[User:Wkitty42/playing with convert template|here]] :)
--[[User:Wkitty42|Wkitty42]] ([[User talk:Wkitty42|talk]]) 14:16, 5 August 2018 (EDT)
== Architectural ideas ==
Would using {{wikipedia|SI base units}} as intermediaries be more maintainable? In essence having subtemplates <code><nowiki>{{convert/from ''unit''}}</nowiki></code> to convert to for example convert from statute miles or ounces to meters or kilograms, and subtemplates <code><nowiki>{{convert/to ''unit''}}</nowiki></code> to for example convert those to nautical miles and pounds.
Possibly a <code><nowiki>{{convert/format}}</nowiki></code> subtemplate for handling decimal precision and whether or not the unit should be hidden.
Regarding parameters, it should be obvious that value, from-unit and to-unit is mandatory and could be unnamed parameters, but parameters for decimal precision and hiding the unit could just as well be named parameters ('''d''' for decimals and and '''h''' for hide unit perhaps).
—[[User:Johan G|Johan G]] ([[User_talk:Johan_G|Talk]] | [[Special:Contributions/Johan_G|contribs]]) 18:31, 26 August 2019 (EDT)

Latest revision as of 22:31, 26 August 2019

Parameter value missing

does this template automatically add the to-unit units? in other words, if i "convert|100|mph|kts" will it put kts after the converted number?

also all i can get out of it is like seen on the convert page at the top where it just says "Parameter value missing" but i know they're there... see my experiment here...

--Wkitty42 (talk) 10:58, 4 August 2018 (EDT)

Hmm. Looking at the template I nearly immediately spotted the problem. I had used named parameters instead of unnamed/numbered parameters (i.e. using {{{value}}} in the template, requiring the value to be written as value=72 when "calling" the template instead of just 72 as was intended).
With that fixed the issue should be limited to "just" units not yet implemented. :-P
Johan G (Talk | contribs) 13:19, 5 August 2018 (EDT)
yes! it is working great! there are some tricks, though...


  • when using the template, you must have 5 |'s in the parameters.
  • if the exprn has round in it, you have to put a value, even zero, in the decimals field.
  • the hide field is the only field that can be empty.



--Wkitty42 (talk) 14:12, 5 August 2018 (EDT)


i forgot to add, check out my sandbox play with this template here :)

--Wkitty42 (talk) 14:16, 5 August 2018 (EDT)

Architectural ideas

Would using SI base units This is a link to a Wikipedia article as intermediaries be more maintainable? In essence having subtemplates {{convert/from ''unit''}} to convert to for example convert from statute miles or ounces to meters or kilograms, and subtemplates {{convert/to ''unit''}} to for example convert those to nautical miles and pounds.

Possibly a {{convert/format}} subtemplate for handling decimal precision and whether or not the unit should be hidden.

Regarding parameters, it should be obvious that value, from-unit and to-unit is mandatory and could be unnamed parameters, but parameters for decimal precision and hiding the unit could just as well be named parameters (d for decimals and and h for hide unit perhaps).

Johan G (Talk | contribs) 18:31, 26 August 2019 (EDT)