[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"?
- From: Gilles Ganault <gilles.ganault@...>
- Date: Fri, 18 Feb 2011 12:53:42 +0100
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:
--file = io.open ('/var/tmp/myfile.txt',w)
local file = io.open ('/var/tmp/myfile.txt',w)
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()".