![]() | |||||||||
| |||||||||
Lua-ApiInput/Output |
[LUA 5.1] io.linesfunction io.lines ( filename )
Opens the given file name in read mode and returns an iterator function that, each time it is called, returns a new line from the file. Therefore, the construction Code for line in io.lines(filename) do {body} endwill iterate over all lines of the file. When the iterator function detects the end of file, it returns nil (to finish the loop) and automatically closes the file. The call io.lines() (with no file name) is equivalent to io.input():lines(); that is, it iterates over the lines of the default input file. In this case it does not close the file when the loop ends. Comments |
||||||||
| © 2007 DracoBlue :: Valid XHTML, CSS, RSS Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC | SourceNet © 2007, DracoBlue :: Page created in 0.06 seconds with 22 queries. | |||||||||