Difference between revisions of "Io.open"

From GiderosMobile
m (→‎Description: fixed some formatting)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
<languages />
 
<languages />
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/io|io]]<br/>
 
=== <translate>Description</translate> ===
 
<translate>This function opens a file, in the mode specified in the string mode. It returns a new file handle, or, in case of errors, nil plus an error message.
 
  
 +
'''<translate>Available since</translate>:''' Gideros 2011.6
 +
<br/>
 +
'''<translate>Class</translate>:''' [[Special:MyLanguage/io|io]]
 +
<br/>
  
The mode string can be any of the following:
+
=== <translate>Description</translate> ===
 +
<translate>This function opens a file, in the mode specified in the string mode. It returns a new file handle, or, in case of errors, nil plus an error message.</translate>
 +
<br/>
  
 +
The mode string can be any of the following:
 +
<br/>
 +
<br/>
 
"r": read mode (the default);
 
"r": read mode (the default);
 +
<br/>
 
"w": write mode;
 
"w": write mode;
 +
<br/>
 
"a": append mode;
 
"a": append mode;
 +
<br/>
 
"r+": update mode, all previous data is preserved;
 
"r+": update mode, all previous data is preserved;
 +
<br/>
 
"w+": update mode, all previous data is erased;
 
"w+": update mode, all previous data is erased;
 +
<br/>
 
"a+": append update mode, previous data is preserved, writing is only allowed at the end of file.
 
"a+": append update mode, previous data is preserved, writing is only allowed at the end of file.
 +
<br/>
 +
<br/>
  
The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode. This string is exactly what is used in the standard C function fopen.</translate>
+
<translate>The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode.
 +
<br/>
 +
This string is exactly what is used in the standard C function fopen.</translate>
 +
<br/>
 
<source lang="lua">
 
<source lang="lua">
 
(file) = io.open(filename,mode)
 
(file) = io.open(filename,mode)
 
</source>
 
</source>
 +
 
=== <translate>Parameters</translate> ===
 
=== <translate>Parameters</translate> ===
 
'''filename''': (string) <translate>filename to open</translate> <br/>
 
'''filename''': (string) <translate>filename to open</translate> <br/>
 
'''mode''': (string) <translate>mode in which to open the file</translate> '''optional'''<br/>
 
'''mode''': (string) <translate>mode in which to open the file</translate> '''optional'''<br/>
 +
 
=== <translate>Return values</translate> ===
 
=== <translate>Return values</translate> ===
 
'''<translate>Returns</translate>''' (file) <translate>file object</translate><br/>
 
'''<translate>Returns</translate>''' (file) <translate>file object</translate><br/>
 +
<br/>

Revision as of 18:40, 2 June 2019


Available since: Gideros 2011.6
Class: io

Description

This function opens a file, in the mode specified in the string mode. It returns a new file handle, or, in case of errors, nil plus an error message.

The mode string can be any of the following:

"r": read mode (the default);
"w": write mode;
"a": append mode;
"r+": update mode, all previous data is preserved;
"w+": update mode, all previous data is erased;
"a+": append update mode, previous data is preserved, writing is only allowed at the end of file.

The mode string can also have a 'b' at the end, which is needed in some systems to open the file in binary mode.
This string is exactly what is used in the standard C function fopen.

(file) = io.open(filename,mode)

Parameters

filename: (string) filename to open
mode: (string) mode in which to open the file optional

Return values

Returns (file) file object