Lua not producing table of functions (IO API)
- by ArtOfCode
I'm working on a basic project in Lua. I've been trying to get data from files using the IO API (as defined here), but when I open a file and give it a handle, it doesn't seem to return a table of functions.
The (erroneous bit of) code:
local unread = fs.list("email/"..from.."/")
local send = ""
for _,file in ipairs(unread) do
local handle = io.open(file,"r")
local text = handle:read("*a")
send = send .. text .. "\n"
handle.close()
fs.delete(file)
end
The fs you see on the first line is a professional filesystem wrapper round the IO API, not my work and perfectly error-free, so that's not the problem. However, when I try to read the file (handle:read()), it throws "attempt to index nil". Tracing it, it turns out that handle itself is nil. Any ideas?