Module:Sandbox/BrownHairedGirl/CanElecResTopTest

This is an old revision of this page, as edited by BrownHairedGirl (talk | contribs) at 12:14, 26 June 2019 (listedargslist = listedargslist .. "electionyear = [" .. electionyear .. "]\n"). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}
local getArgs = require('Module:Arguments').getArgs
	
function p.main(frame)
	local rawcats = {}
	local nvalid = 0
	local args = getArgs(frame)

	local listedargslist = "";
	for i, v in ipairs(frame.args) do
		listedargslist = listedargslist .. "* i=[" .. i .. "]       v = [" .. v .."]\n"
	end
	
	local electionyear =args['electionyear'];
	
	listedargslist = listedargslist .. "electionyear = [" .. electionyear .. "]\n"
	
	if ((electionyear == nil) or (mw.ustring.match(electionyear, "^%s*$") ~= nil)) then
		return listedargslist .. "[[:Category:CanElecResTopTest with nil value]]"
	elseif (mw.ustring.match(electionyear, "^%s*%d%d%d%d%s*$") ~= nil) then
		return listedargslist .. "[[:Category:CanElecResTopTest with bare year]]"
	elseif (mw.ustring.match(electionyear, "^.*%s+%d%d%d%d%s*$") ~= nil) then
		return listedargslist .. "[[:Category:CanElecResTopTest with something before year]]"
	else
		return listedargslist .. "[[:Category:CanElecResTopTest with unrecognised value]]"
	end
end

return p