Jump to content

Module:IncrementParams

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Amadalvarez (talk | contribs) at 08:13, 4 April 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.

-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign. 
local increment = 1

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
|header10  = {{#if:{{{ra|{{{ar|}}}}}}
                   {{{dec|}}}
                   {{{dist_allum|{{{dist_al|{{{dist_ly|}}}}}}}}}{{{dist_pc|}}}{{#property:P2583|from={{{item|}}}}}
                   {{{apar_mag_v|{{{magapa_v|{{{appmag_v|}}}}}}}}}{{#property:P1215|from={{{item|}}}}}
                   {{{dim_v|{{{tam_v|{{{size_v|{{{dimensions|}}}}}}}}}}}}{{#property:P59|from={{{item|}}}}}
                   {{{constellacio|{{{constelación|{{{constellation|{{{constellation name|{{{const|}}}}}}}}}}}}}}}
                   {{{formatper|{{{format_per|{{{conte|}}}}}}}}}{{#property:P527|from={{{item|}}}}}
                   {{{z|{{{redshift|}}}}}}{{#property:P1090|from={{{item|}}}}}
                   | Dades d'observació}}

| label15  = [[època (astronomia)|Època]]  
| data15   = {{#invoke:Wikidades | claim | property=P6259 | value={{{epoch|}}} |formatting=$1}}

|label20   = [[Ascensió recta]] (α)
| data20   = {{#if:{{{ar|}}}|{{{ar|}}}|{{#invoke:Wikidades | claim | property=P6257 | formatting=table |list=false |references=si |rowformat={{((}}Deg2HMS{{!}}$0{{!}}p=4{{!}}sup=si{{))}}$R0}} }}

| label25  = [[Declinació (astronomia)|Declinació]] (δ)  
| data25   = {{#if:{{{dec|}}}|{{{dec|}}}|{{#invoke:Wikidades | claim | property=P6258 | formatting=table |list=false |references=si |rowformat={{((}}Deg2DMS{{!}}$0{{!}}p=4{{))}}$R0 }} }}

|label30   = Distància de la Terra
|data30    = {{ifempty|{{{dist_allum|{{{dist_al|{{{dist_ly|}}}}}}}}} | {{{dist_pc|}}} | {{#invoke:Wikidades | claim | property=P2583  | list=firstrank | formatting=table | rowformat=$0$R0 | colformat0=unitcode | references=si }} }}

|label40   = [[Magnitud aparent]] ([[banda V|V]])
|data40    = {{#invoke:Wikidades | claim | property=P1215 | qualifier=P1227 | formatting = table | whitelist1 = Q4892529 | value={{{apar_mag_v|{{{magapa_v|{{{appmag_v|}}}}}}}}} | list=firstrank |references=si |rowformat=$0$1$R0 |rowsubformat1 = }} <!--whitelist banda V-->

|label45   = Diàmetre angular
|data45    = {{#invoke:Wikidades | claim | property=P5348 | value={{{diametre_angular|}}}  | list=firstrank |formatting=table |rowformat=$0$R0 | colformat0=unitcode |references=si}}

|label50   = [[Constel·lació]]
|data50    = {{#invoke:Wikidades | claim | property=P59 | value={{{constellacio|{{{constelación|{{{constellation|{{{constellation name|{{{const|}}}}}}}}}}}}}}} |formatting=list |list=true }}

|label70  = Format per
|data70   = {{Llista desplegable condicional|{{#invoke:Wikidades | claim | property=P527 | value={{{formatper|{{{format_per|{{{conte|}}}}}}}}} | formatting=table |rowformat=$0}}|100}}

|label75   = [[Desplaçament cap al roig]]
|data75    = {{#invoke:Wikidades | claim | property=P1090 | value={{{z|{{{redshift|}}}}}}  | list=firstrank |formatting=table |rowformat=$0$R0 | colformat0=unitcode |references=si}}

|label80   = Darrer periheli
|data80    = {{{last_p|}}}

|label85   = Proper periheli
|data85    = {{{next_p|}}}

|label90   = Semieix major
|data90    = {{#invoke:Wikidades | claim | property=P2233 | value={{{semieix_major|}}} | formatting=unitcode }}

|label95   = Període orbital
|data95    = {{#invoke:Wikidades | claim | property=P2146 | value={{{periode_orbital|}}} | formatting=unitcode }}

| label100  = [[Excentricitat orbital|Excentricitat]]  
| data100   = {{#invoke:Wikidades | claim | property=P1096 | value={{{excentricitat|}}} | formatting=unit | list=firstrank |references=si |rowformat=$0$R0}}

]==========]

-- STEP 4: Save this module.

-- STEP 5: You can now output the incremented text with the following code:
--                {{subst:#invoke:IncrementParams|main}}
-- Or you can simply copy and paste the text from this module's documentation.

-- STEP 6: Check the output! In rare cases this module might produce false positives.
-- For example, it will change the text "[[Some link|foo3=bar]]" to "[[Some link|foo4=bar]]".
-- You can use the "show changes" function in the edit window of the template you are editing
-- to find any false positives.

-- STEP 7: When you are finished, undo your changes to this page, so that the next person
-- won't be confused by seeing any non-default values. Thanks for using this module!

local p = {}
 
local function replace(prefix, num, suffix)
    return '|' .. prefix .. tostring(tonumber(num) + increment) .. suffix .. '='
end
 
function p.main(frame)
    -- Increment the template text.
    templatetext = mw.ustring.gsub(templatetext, '|(%s*%a?[%a_%-]-%s*)([1-9]%d*)(%s*[%a_%-]-%a?%s*)=', replace)
    -- Add pre tags and escape html etc. if the pre option is set.
    if frame and frame.args and frame.args.pre and frame.args.pre ~= '' then
        templatetext = mw.text.nowiki(templatetext)
        templatetext = '<pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; '
            .. 'white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">' 
            .. templatetext .. '</pre>'
    end
    return templatetext
end
 
return p