Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Matroc/TestmvloadData
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} -- DEFINE LOAD_T1 FUNCTION HERE function load_t1(t1_loaded, stuff, t1 ,tabletoload) if pcall(function()t1 = mw.loadData(tabletoload) end) then t1_loaded = 1 -- LOAD TABLE FIRST TIME and SET VARIABLE t1_loaded to 1 AS IT IS NOW LOADED! stuff = stuff .. "TABLE t1 is not LOADED -- LOADED TABLE t1 via function load_t1<BR />" else error ("Unable to load table t1") -- THIS IS LUA ERROR - FAILURE FOR LOADING TABLE end return t1_loaded, stuff, t1 end -- MAIN MODULE FUNCTION HERE function p.testloader ( frame ) local stuff = "" ---- RETURN SOMETHING local t1 = {} ---- local array for table1 local t1_loaded = 0 ---- NO TABLE 1 is NOT LOADED! local tabletoload = "Module:" .. frame.args[1] local lukfor = frame.args[2] or "" local foundit = "" -- NOT LOADING TABLE t1 in beginning -- DOING A LOT OF THINGS WHICH MIGHT NOT REQUIRE A TABLE BEING LOADED -- AND POSSIBLY DO A RETURN HERE -- NOT DONE YET! HMM HAS TABLE BEEN LOADED - NOW I NEED TO CHECK IF THE TABLE t1 IS LOADED OR NOT AND DO if t1_loaded == 0 then -- IF TABLE IS NOT LOADED SO LOAD TABLE T1 t1_loaded, stuff, t1 = load_t1(t1_loaded, stuff, t1 ,tabletoload) end if t1_loaded == 1 then -- DO SOMETHING stuff = stuff .. "TABLE t1 IS LOADED -- DOING SOMETHING<BR />" end -- DO SOME MORE PROCESSING MIGHT RETURN FROM HERE OR -- NOW NEED TO DO SOMETHING WITH TABLE t1 AGAIN -- DO SOME MORE PROCESSING -- NEED TO DO ONE MORE THING WITH TABLE t1 if t1_loaded == 0 then -- IF TABLE IS NOT LOADED SO LOAD TABLE T1 t1_loaded, stuff, t1 = load_t1(t1_loaded, stuff, t1 ,tabletoload) end if t1_loaded == 1 then stuff = stuff .. "TABLE t1 is ALREADY LOADED<BR />" -- DO SOMETHING foundit = t1[lukfor] if foundit ~= nil then stuff = stuff .. " FOUND : " .. lukfor .. " " .. t1[lukfor] else stuff = stuff .. " - " .. lukfor .. " was NOT FOUND in TABLE: " .. tabletoload end end return stuff end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Matroc/TestmvloadData/doc
(
edit
)