Module:Johnuniq/load

From Wikipedia

Documentation for this module may be created at Module:Johnuniq/load/doc

-- This is documented in the Scribunto manual under mw.loadData:
--   #t is not supported.

-- 2015-02-07: Demonstrate problem where #t fails (it returns 0)
-- where t is a table accessed via mw.loadData.
-- In the debug window:  num,sim,num2 = p.main('load')
--                  or:  num,sim,num2 = p.main('require')

local function main(how)
	local data
	if how == 'load' then
		data = mw.loadData("Module:Johnuniq/data")
	else
		data = require("Module:Johnuniq/data")
	end
	local tnumbered = data.numbered
	local tsimple = data.mixed.simple
	local tnumbered2 = data.mixed.complex.numbered2
	mw.log(string.format('#tnumbered = %d, #tsimple = %d, #tnumbered2 = %d',
						#tnumbered, #tsimple, #tnumbered2))
	return tnumbered, tsimple, tnumbered2
end

return { main = main }