Modul:DecodeArgs: Unterschied zwischen den Versionen
Aus GEOWiki@LMU
Zeile 15: | Zeile 15: | ||
do | do | ||
start = stop + 2 | start = stop + 2 | ||
− | stop = string.find( s, ', ', start ) | + | stop = string.find( s, ', ', start ) |
end | end | ||
+ | end | ||
+ | if stop == nil then | ||
+ | stop = string.len | ||
+ | else | ||
+ | stop = stop - 1 | ||
end | end | ||
Version vom 25. April 2020, 18:19 Uhr
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 else stop = stop - 1 end r = string.sub( s , start, stop ) return r end return p