lua-users home
lua-l archive

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


On Tuesday 14, Digital wrote:
> Well the "data" var lets say is simply a picture or file alike from
> io.open("file.dat","rb"); etc ...

io.open() returns a file "object" not the contents of the file.  The file 
object is a userdata value that hold a "FILE *" pointer.

-- open binary file
local file = io.open("file.dat", "rb")
-- read file contents
local data = file:read("*a") -- '*a' means read the whole file.
file:close()

-- pass binary data to 'testfunc'
local somevar = require "modulename"
somevar.testfunc(data)

-- 
Robert G. Jakabosky