Module:LoadDataError
Documentation for this module may be created at Module:LoadDataError/doc
er = {};
local er_data = mw.loadData( 'Module:LoadDataError/Data' );
local er_data2 = mw.loadData( 'Module:LoadDataError/Data2' );
local_data ={
a = {'Joe', 'Bob'},
b = {'John', 'Doe'},
c = {'a','b','c','d','e'};
};
function er.test( frame )
local str = "== With mw.loadData ==\n";
for k, v in pairs( er_data ) do
local count = 0;
local list = ""
for i, j in ipairs( v ) do
list = list .. "*" .. i .. " = " .. j .. "\n";
count = count + 1;
end
str = str .. "Table '" .. k .. "' has " .. tostring(count) .." elements and length " .. #v .. "\n" .. list .. "\n<br/>";
end
local str = str .. "\n== With local table ==\n";
for k, v in pairs( local_data ) do
local count = 0;
local list = ""
for i, j in ipairs( v ) do
list = list .. "*" .. i .. " = " .. j .. "\n";
count = count + 1;
end
str = str .. "Table '" .. k .. "' has " .. tostring(count) .." elements and length " .. #v .. "\n" .. list .. "\n<br/>";
end
return str;
end
function er.test2( frame )
local str = "== With mw.loadData ==\n";
for k, v in pairs( er_data2.a ) do
local count = 0;
local list = ""
for i, j in ipairs( v ) do
list = list .. "*" .. i .. " = " .. j .. "\n";
count = count + 1;
end
str = str .. "Table '" .. k .. "' has " .. tostring(count) .." elements and length " .. #v .. "\n" .. list .. "\n<br/>";
end
for k, v in pairs( er_data2.b ) do
local count = 0;
local list = ""
for i, j in ipairs( v ) do
list = list .. "*" .. i .. " = " .. j .. "\n";
count = count + 1;
end
str = str .. "Table '" .. k .. "' has " .. tostring(count) .." elements and length " .. #v .. "\n" .. list .. "\n<br/>";
end
return str;
end
return er;