Modulo:MultiBand

Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:MultiBand/man (modifica · cronologia)
Sandbox: Modulo:MultiBand/sandbox (modifica · cronologia) · Sottopagine: lista · Test: Modulo:MultiBand/test (modifica · cronologia · esegui)
Questo modulo serve in appoggio al Template:MultiBand per permettere un numero illimitato di cambi di denominazioni societarie e/o dei colori della società.
Vedi il manuale del template per l'uso.
-- modulo per gestire l'omonimo template
-- la gestione dei parametri con numeri progressivi prende spunto da Modulo:Tracce
local args = {}
local maxInterval = 0
local function getValue(param, year)
result = ""
for i=1,maxInterval do
currentYear = args["anno" .. i]
if tonumber(currentYear) <= tonumber(year) then
temp = args[param .. i]
if temp ~= nil and temp ~= "" then
result = temp
end
end
end
return result
end
local p = {}
function p.get(frame)
local pframe = frame:getParent()
for k, v in pairs( pframe.args ) do
-- mappo i parametri del template
if v ~=nil then args[k] = v end
-- cerco l'intervallo più recente
num = string.match(k, "anno(%d+)$")
if num then
if tonumber(num) > tonumber(maxInterval) then
maxInterval = num
end
end
end
local year = args["anno"]
if year == nil or year == "" then year = getValue("anno", os.date('%Y')) end
return getValue(frame.args[1], year)
end
return p