lua-users home
lua-l archive

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


On 02/18/2011 06:53 AM, Gilles Ganault wrote:
Hello

	I'm trying to create a text file, and google for samples on how to
do this, but regardless of using a global or local variable to hold
the file descriptor, I get the following error:

"attempt to index global 'file' (a nil value)"
"attempt to index local 'file' (a nil value)"

Here's the script:
=============
#!/var/tmp/lua

--file = io.open ('/var/tmp/myfile.txt',w)
local file = io.open ('/var/tmp/myfile.txt',w)

file:write(Blah")

file:close()
=============

What am I doing wrong?

I'll piggy-back on this question to ask what the difference is between
"io.stdin:read()" and "io.read()".

Thank you.



You probably meant file:write("Blah") with two double quotes right?-Patrick