io
close
function io.close(file?: file*)
-> suc: boolean?
2. exitcode: ("exit"|"signal")?
3. code: integer?
Close file or default output file.
exitcode:
| "exit"
| "signal"flush
function io.flush()
Saves any written data to default output file.
input
function io.input(file: string|file*)
Sets file as the default input file.
lines
function io.lines(filename?: string, ...string|integer|"L"|"a"|"l"...(+1))
-> fun():any, ...unknown
for c in io.lines(filename, ...) do
body
end...(param):
| "n" -- Reads a numeral and returns it as number.
| "a" -- Reads the whole file.
-> "l" -- Reads the next line skipping the end of line.
| "L" -- Reads the next line keeping the end of line.open
function io.open(filename: string, mode?: "a"|"a+"|"a+b"|"ab"|"r"...(+7))
-> file*?
2. errmsg: string?
Opens a file, in the mode specified in the string mode.
mode:
-> "r" -- Read mode.
| "w" -- Write mode.
| "a" -- Append mode.
| "r+" -- Update mode, all previous data is preserved.
| "w+" -- Update mode, all previous data is erased.
| "a+" -- Append update mode, previous data is preserved, writing is only allowed at the end of file.
| "rb" -- Read mode. (in binary mode.)
| "wb" -- Write mode. (in binary mode.)
| "ab" -- Append mode. (in binary mode.)
| "r+b" -- Update mode, all previous data is preserved. (in binary mode.)
| "w+b" -- Update mode, all previous data is erased. (in binary mode.)
| "a+b" -- Append update mode, previous data is preserved, writing is only allowed at the end of file. (in binary mode.)output
function io.output(file: string|file*)
Sets file as the default output file.
popen
function io.popen(prog: string, mode?: "r"|"w")
-> file*?
2. errmsg: string?
Starts program prog in a separated process.
mode:
| "r" -- Read data from this program by `file`.
| "w" -- Write data to this program by `file`.read
function io.read(...string|integer|"L"|"a"|"l"...(+1))
-> any
2. ...any
Reads the file, according to the given formats, which specify what to read.
...(param):
| "n" -- Reads a numeral and returns it as number.
| "a" -- Reads the whole file.
-> "l" -- Reads the next line skipping the end of line.
| "L" -- Reads the next line keeping the end of line.tmpfile
function io.tmpfile()
-> file*
In case of success, returns a handle for a temporary file.
type
function io.type(file: file*)
-> "closed file"|"file"|`nil`
Checks whether obj is a valid file handle.
return #1:
| "file" -- Is an open file handle.
| "closed file" -- Is a closed file handle.
| `nil` -- Is not a file handle.write
function io.write(...any)
-> file*
2. errmsg: string?
Writes the value of each of its arguments to default output file.