Scaleform Studio Lua API Reference: io.stdin namespace reference

io.stdin namespace reference

Description

The standard input file handle descriptor.

Functions

Parameters

file :

string

The file handle to close.

Returns
This function does not return any values.
Parameters
This function does not accept any parameters.
Returns
This function does not return any values.
Parameters

file :

string

The name of the file to be read.

Returns

fun(any*:any*)

The iterator function to read the lines of the file.

The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..

The function will open the file and 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.

Parameters

fmt :

string*

The type of data to read. The formats are:

  • "*l": Reads the next line skipping the end of line, returning nil on end of file. This is the default format.
  • "*n": reads a number; this is the only format that returns a number instead of a string.
  • "*a": reads the whole file, starting at the current position. On end of file, it returns the empty string.
The * notation indicates that there may be zero or more instances of the specified type.
Returns
This function does not return any values.

For each format, the function returns a string (or a number) with the characters read, or nil if it cannot read data with the specified format. When called without formats, it uses a default format that reads the next line.

Parameters

pos :

string

A string indicating the position to start seeking from. Can be "set" for beginning of file, "cur" for current position, "end" for end of file. Default is "cur"

offset :

integer?

An offset to the file. Default is 0.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

string

An error message in case of failure.

If successful, the function returns the final file position, measured in bytes from the beginning of the file. If this function fails, it returns nil, plus a string describing the error.

Parameters

mode :

string

The buffering mode of the input file descriptor. The three available modes are:

  • "no": no buffering; the result of any output operation appears immediately to the input file handle.
  • "full": full buffering; output operation is performed only when the buffer is full.
  • "line": line buffering; output is buffered until a newline is output or there is any input from some special files (such as a terminal device).

size :

integer?

Specifies the size of the buffer, in bytes. The default is an appropriate size.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.
Parameters

args :

any(string,integer)

The arguments to ouptut.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns
This function does not return any values.
 io.stdin.close (file)
Closes an open input file handle.
 file : string
The file handle to close.
A string of characters.  io.stdin.flush ()
Flushes the default stdin file.
 io.stdin.lines (file) : fun(any*:any*)
Opens the standard input file in read mode and returns an iterator function that, each time it is called, returns a new line from the file.
 file : string
The name of the file to be read.
 fun(any*:any*)
The iterator function to read the lines of the file.
The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..
This value may be an instance of any type.  io.stdin.read (fmt)
Reads the standard input file according to the format that specify what to read.
 fmt : string*
The type of data to read. [more...]
The * notation indicates that there may be zero or more instances of the specified type.
 io.stdin.seek (pos, offset) : nil, string
Seeks and get the file position (of the standard input file), measured from the beginning of the file, to the position given by offset plus a base specified by the string pos.
 pos : string
A string indicating the position to start seeking from. [more...]
 offset : integer?
An offset to the file. [more...]
The ? notation indicates that this type is optional: there may be zero or one instances of it.
 nil  string
An error message in case of failure.
A strictly integral numeric value, with no decimal component.  io.stdin.setvbuf (mode, size)
Sets the buffering mode for the input file descriptor.
 mode : string
The buffering mode of the input file descriptor. [more...]
 size : integer?
Specifies the size of the buffer, in bytes. [more...]
The ? notation indicates that this type is optional: there may be zero or one instances of it.
 io.stdin.write (args)
Writes the value of arguments to the input file handle.
 args : any(string,integer)
The arguments to ouptut.
The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Nothing; the absence of a value.Indicates a table.
This documentation uses the term table to mean an anonymous, temporary Lua table that contains named data values. You typically use these tables to pass data or settings to a function, or to hold data returned by a function.
Indicates an object.
This documentation uses the term object to mean a named Lua table or userdata value that maintains a state. Some object types may have multiple instances existing at the same time, each with its own state; these objects typically have creation functions or accessors that you must call in order to get an instance. Some object types have only one instance, which you always access through the object's name.
Indicates a named variable within a namespace, object or table; or an element within an enumeration.Indicates a code sample.Indicates an enumeration.
This documentation uses the term enumeration to mean a named Lua table that contains only a set of constant values. These values typically identify a predefined set of options for some setting or behavior. You might pass an enumeration value to a function, or test the value returned by a function against the items in the enumeration to see which option is currently set.
Indicates a named variable within a namespace or object that has a pre-set constant value.Indicates a category: a semantic grouping of related API elements.Indicates a namespace.
This documentation uses the term namespace to mean a named Lua table that exists in only one single instance, intended as a container for an interface of related objects, functions and data variables.
Indicates an output value returned by a function.Indicates a named function within a namespace or object.Indicates an input parameter for a function.