Modul:DecodeArgs

Aus GEOWiki@LMU
Wechseln zu:Navigation, Suche

Die Dokumentation für dieses Modul kann unter Modul:DecodeArgs/Doku erstellt werden

local p = {}

function p.decode( frame )
    local r = ''
    local start = 1
    local stop  = 1
    local j = tonumber(frame.args[1])
    local s = frame.args[2] or ''

    if j == 1 then
        stop = string.find( s, ', ', start )
    end
    if j ~= 1 then
        for i = 1,j 
        do 
            start = stop + 2
            stop = string.find( s, ', ', start )
         end
    end
    if stop == nil then
        stop = string.len(s)
    else
        stop = stop - 1
    end

    r = string.sub( s , start, stop )

    return r
end

return p