lua-users home
lua-l archive

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


I've been using lua for almost 15 years and I've never had to use the io package before now. I can't get it to work. The fragment below returns a nil string.
 
I know the file name (sName, which is a full path) is good and that the file has multiple lines of text inside it. I printed the handle (nFile) returned by io.open and it is non zero.
 
 
nFile, sMsg = io.open( sName, "r" )
if not nFile then Exit(sMsg) end
 
for i = 1, 10000000 do
  local sLine = io.read("*line")
On the first call to io.read, sLine is returned as nil. I also tried using "*number" and the returned value was like 1.e-312, or garbage. Problem is, I can't figure out how to debug it beyond this point.
 
Michael