lua functions

I’ve come from C, so I’m not doing too badly picking up lua - but being able to return multiple values from functions is new as is the fact that the type of the variable is not specified. Example below

function nlst(u)
local t = {}
local p = url.parse(u)
p.command = “nlst”
p.sink = ltn12.sink.table(t)
local r, e = ftp.get§
return r and table.concat(t), e
end

In the above, what do I need to do when calling this function? Something like:

local mytable = nlst

What about the e? I’m assuming this is error? [import]uid: 31718 topic_id: 6503 reply_id: 306503[/import]

Yes, e will contain an error string if r is nil.

To call, it’s the same syntax as you’ve already used:

  
local data, err = nlst(url)  
  
if not data then print(err) end  
  

[import]uid: 3953 topic_id: 6503 reply_id: 24097[/import]