190
C H A P T E R 5
Scripting
local ret = false
while true do
local s1 = f1:read (256)
local s2 = f2:read (256)
if not (s1 or s2) then
break
elseif s1 ~= s2 then
ret = true
break
end
end
f1:close()
f2:close()
return ret
end
Now all preparations are done, and we can start to read the
INI
file. The
configuration counter and the name of the current configuration are set to
default values, and, if the
INI
file exists, it is read line-by-line using the
io.lines()
function. For each line, we run through the functions in table
parser_func
and check to see whether a function applies. By now we
should have the current configuration count in the variable
ccount
and the
current configuration name in the variable
config_name
:
ccount = 0
config_name = ""
-- ini file parsing
if os.stat(ininame) then
for line in io.lines(ininame) do
for _,f in pairs(
parser_funcs) do
if f(line) then break end
end
end
end
Next, we allow the user to select the configuration to switch to. To do this,
we fetch the list of files contained in the folder
CHDK/CONFIGS/
. If this folder
does not exist, we just use the empty list.
If the list of files is not empty, we sort the files in alphabetic order to
determine the index of the current configuration, since we want to display
this configuration to the user. Then, in the following
while
loop, the user
can use the
LEFT
and
RIGHT
buttons for scrolling in the list. The
SET
button
can be used to select a configuration.
Содержание 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 ...