Eyeon:Script/Reference/Libraries/io/read
From VFXPedia
Contents |
IO: fh : read / io.read
Arguments
fh:read(format)
- format (optional, string)
A string describing the format that read() will use to retrieve the data from the input
Returns
A string (or number) obtained from the default input file.
Remarks
The fh:read() function reads data from the file in filehandle 'fh'. It uses a format argument, which specifies how the input should be read, which can be any one of the following:
"*n" - reads a number - this is the only format which returns a number instead of a
string.
"*l" - reads an entire line, (skipping the end of the line) and returns nil at the end of the file. This is the default, if no format is specified.
"*a" - reads the entire file, starting from the current position. At the end of the file, it will return an empty string.
number - Reads a string with the specified number of characters, or if the file is binary, with the specified number of bytes..
Requirements
- eyeonScript 5.0
- Fusion 5.0
Examples
-- function -- a basic function which copies the file -- source to a new file named dest -- this is an example function only, -- it does no error checking at all function copyfile(src_path, dest_path) src = io.open(src_path,"rb") dest = io.open(dest_path,"wb") bytes = src:read(65536) repeat ret = dest:write(bytes) bytes = src:read(65536) until bytes == nil src:close() dest:close() end copyfile(src,dest)