[5.1.4/newbie] "attempt to index ... 'file' (a nil value)"?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"?
- From: Gilles Ganault <gilles.ganault@...>
- Date: 2011年2月18日 12:53:42 +0100
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.