5.4 Lua primer
105
ret,msg,no = file:write(value1,...)
writes the values passed in the parameters to the specified file. Only
numeric or string values are allowed as parameters. In case of an error,
ret
is
nil
, and an error message is given in
msg
, an error code in
no
.
Operating system functions
Only some of the standard
Lua
OS functions are supported in the CHDK.
r, msg = os.remove(filename)
deletes a file or directory with the specified name. If it succeeds,
true
is
returned. If it fails,
nil
is returned, followed by an error message. The func-
tion will fail on an attempt to delete a directory that is not empty..
r,msg = os.rename(oldname,newname)
renames the file or directory specified in
oldname
to the name given in
newname
. If it succeeds,
true
is returned. If it fails,
nil
is returned, followed
by an error message.
Caution!
Attempting to rename a
nonempty directory
may result in file
system corruption! Attempting to
move a file to another directory
by re-
naming it can lead to unpredictable results. The
rename()
function may
produce unpredictable results if the
target name already exists.
t = os.time(table)
returns the time specified in
table
as a single number (number of seconds
since January 1, 1970). The table has the following keywords: “year”,
“month”, “day”, “hour”, “min”, “sec”, “dst”, “wday”. “dst” represents a Bool-
ean value that is
true
for daylight savings time; “wday” represents the day
of the week (Sunday = 1).
If the parameter
table
is missing, the function delivers the current date
and time as a number:
s = os.date(format, time)
The
date()
function works the other way round. The format string speci-
fies how a numeric date value will be converted into a string. If the second
parameter is missing, the current date is used. The format string can con-
tain short control sequences (‘%’ followed by a letter) that will be replaced
by year, month, day, etc. The following control sequences are possible:
Summary of Contents for Camera
Page 1: ......
Page 2: ...The Canon Camera Hackers Manual ...
Page 3: ......
Page 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Page 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Page 25: ...16 CH APTER 3 ...
Page 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Page 213: ...204 CH APTER 6 ...
Page 253: ...244 AP PENDIX ...