lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


perhaps you could use something along these lines:



db = {5, 76, 124, 76, 234}

setmetatable(db, {
		__call = function()
			    local count = 0
			    return function()
				      count = count + 1           -- replace with code that gets
the next val
				      return db[count]             -- from your database
				   end
			 end

})


for v in db() do
  print(v)
end


look here for more examples:
http://www.lua.org/pil/7.1.html