Difference between revisions of "File:Read"

From GiderosMobile
Line 2: Line 2:
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
=== Description ===
 
=== Description ===
Reads the file file, according to the given formats, which specify what to read. 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 entire next line (see below).  
+
<translate>Reads the file file, according to the given formats, which specify what to read. 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 entire next line (see below).  
  
  
Line 14: Line 14:
 
"*l": reads the next line (skipping the end of line), returning nil on end of file. This is the default format.  
 
"*l": reads the next line (skipping the end of line), returning nil on end of file. This is the default format.  
  
number: reads a string with up to this number of characters, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file.
+
number: reads a string with up to this number of characters, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file.</translate>
 
<source lang="lua">
 
<source lang="lua">
 
(string) = file:read(format1,...)
 
(string) = file:read(format1,...)
 
</source>
 
</source>
 
=== Parameters ===
 
=== Parameters ===
'''format1''': (string) format <br/>
+
'''format1''': (string) <translate>format</translate> <br/>
'''...''': (string) more optional formats '''optional'''<br/>
+
'''...''': (string) <translate>more optional formats</translate> '''optional'''<br/>
 
=== Return values ===
 
=== Return values ===
'''Returns''' (string) read string from file<br/>
+
'''Returns''' (string) <translate>read string from file</translate><br/>

Revision as of 14:38, 23 August 2018

Available since: Gideros 2011.6

Description

Reads the file file, according to the given formats, which specify what to read. 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 entire next line (see below).


The available formats are 


"*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.

"*l": reads the next line (skipping the end of line), returning nil on end of file. This is the default format.

number: reads a string with up to this number of characters, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file.

(string) = file:read(format1,...)

Parameters

format1: (string) format
...: (string) more optional formats optional

Return values

Returns (string) read string from file

There are no pages that use this file.