File:Seek: Difference between revisions

From GiderosMobile
Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === Sets and gets the file position, measured from the beginning of the file, to the position given by off..."
 
No edit summary
Line 13: Line 13:
  The default value for whence is "cur", and for offset is 0. Therefore, the call file:seek() returns the current file position, without changing it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); and the call file:seek("end") sets the position to the end of the file, and returns its size.
  The default value for whence is "cur", and for offset is 0. Therefore, the call file:seek() returns the current file position, without changing it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); and the call file:seek("end") sets the position to the end of the file, and returns its size.
<source lang="lua">
<source lang="lua">
(number), = file:seek(whenceoffset,)
(number) = file:seek(whence,offset)
</source>
</source>
'''whence:''' (string) setting the base point for offset '''optional'''<br/>
'''whence''': (string) setting the base point for offset '''optional'''<br/>
'''offset:''' (number) offset to set position to '''optional'''<br/>
'''offset''': (number) offset to set position to '''optional'''<br/>
'''Returns''' (number) the position in file measured in bytes from the beginning of the file<br/>
'''Returns''' (number) the position in file measured in bytes from the beginning of the file<br/>

Revision as of 09:21, 23 August 2018

Available since: Gideros 2011.6

Description

Sets and gets the file position, measured from the beginning of the file, to the position given by offset plus a base specified by the string whence, as follows:

"set": base is position 0 (beginning of the file); "cur": base is current position; "end": base is end of file;

In case of success, function seek 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. 


The default value for whence is "cur", and for offset is 0. Therefore, the call file:seek() returns the current file position, without changing it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); and the call file:seek("end") sets the position to the end of the file, and returns its size.
(number) = file:seek(whence,offset)

whence: (string) setting the base point for offset optional
offset: (number) offset to set position to optional
Returns (number) the position in file measured in bytes from the beginning of the file

There are no pages that use this file.