Jump to content

Module:Sandbox/Squc/Test

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Squc (talk | contribs) at 09:56, 17 August 2013. The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
-- Testing module

local p={}

function p.test1 (frame)
    local input = frame.args[1]
    local find = frame.args["find"]
    local output = ""
    for i=1, #input do 
        output = (output..mw.ustring.sub(input, i, i)..",")
        if find and mw.ustring.sub(input,i,i) == find then output=(output.."[Found at "..i.."]") end
    end
    return output
end

function p.test2 (frame)
    local a = frame.args[1]
    local b = frame.args[2]
    local c = frame.args[3]
    if not a then a = "nil" end
    if not b then b = "nil" end
    if not c then c = "nil" end
    return "a = "..a..", b = "..b..", c = "..c.."."
end

return p