Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Sandbox/Matroc/TestmvloadData

From Wikipedia, the free encyclopedia
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