5.4 Lua primer
103
IO functions
The
Lua
IO library provides access to file input and output. Using these
functions, it is possible to read and write files located on the memory card.
We will only give a short overview of the most important IO functions. Ex-
amples for the application of these functions are found in section 5.7.1.
file, msg, no = io.open(filename, mode)
opens a file with the specified name and in the specified mode. A
“b”
appended to the mode strings indicates a binary file:
"r"
Read mode (the default if the
mode
parameter is omitted).
"w"
Write mode. A new file is created, and existing files are overwritten.
"a"
Append mode. Appends to the end of an existing file.
In case of an error, the return variable
file
is
nil
and an error message is
given in
msg
, an error code in
no
.
ret, msg, no = io.close(file)
ret, msg, no = file:close()
Closes the specified file. In case of an error,
ret
is
nil
, and an error message
is given in
msg
, an error code in
no
.
ret, msg, no = io.flush()
Performs all outstanding buffered write operations and makes sure that all
written data is physically stored.
ret, msg, no = file:lines()
Creates an iterator over the lines in a text file. It can be used in the follow-
ing way:
for line in file:lines()
do ... end
Here, the variable
line
will subsequently contain each line in the specified
file. If no more lines are available,
nil
will be returned.
Содержание Camera
Страница 1: ......
Страница 2: ...The Canon Camera Hackers Manual ...
Страница 3: ......
Страница 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Страница 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Страница 25: ...16 CH APTER 3 ...
Страница 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Страница 213: ...204 CH APTER 6 ...
Страница 253: ...244 AP PENDIX ...