lua-users home
lua-l archive

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


> 1) Does io.output() close the previously default output file (if
> any) or should the latter be closed with io.close() before calling
> io.output() to select another output file?

io.output does not close any file. The program should close the previous
default output file (otherwise the garbage collection will do it, but
maybe too late).


> However, file.close() seems to return true on success, but calls an
> error on failure.

Are you sure?


> 3) In which mode does io.input(filename) open the file? "r" or "w"?

"r" (it's implicit, as it will be an input file). "text mode" means
that it is not in bynary mode.


> 4) Does io.input() return a file object (handle) even when an argument is 
> given? It seems so.

Yes. It (and io.output) always returns the current handle (after the
eventual modification).

-- Roberto