Home  Contents

rawio:write

Rawio Core4 Lua Event System

SYNOPSIS

handle:write(data [, data, ...])

DESCRIPTION

Writes data to the open file. The number of bytes written may be less than the length of data if there is insufficient space on the underlying physical medium.

For real files (as opposed to, e.g. devices or network connections), the file index is advanced by the number of files written. If the file was opened in append mode, the file index is moved to the end of the file before writing takes place.

If multiple arguments are given, the contents of the variables are written one after the other just as if multiple write() calls had been made.

RETURN VALUE

On success, returns the number of bytes written, on failure, returns nil. In case of an error, the error can be retrieved using rawio:lastError().

NOTES

Please note that Lua considers the number '0' true. Using
if (handle:write(...)) then print("OK") end
will happily print OK if zero bytes where written.

EXAMPLE

>  > 
handle = rawio.attach(1) handle:write("Hello", " ", "World\n")
Hello World

SEE ALSO