5.7 Example scripts
193
later want to rename this file (e.g., on a PC) and give it a more meaningful
name:
os.mkdir(configs)
if newconf then
ccount = 1
new_name =
"conf"..ccount..".CFG"
copy_file(current_config,
configs.."/"..new_name)
print("Saved as "..new_name)
end
Now we are ready to switch to the selected configuration. We update the
INI
file; if the current configuration has changed or if the user wants to
switch the configuration, we copy the selected configuration file to the
current configuration. So, by not selecting a different configuration file and
pressing
SET
, the user can reset the current configuration to its initial state.
If the user does not switch or reset the configuration, we simply update the
INI
file:
if selected_config then
write_ini(
selected_config, ccount)
if changed or config_name ~=
selected_config then
copy_file(configs.."/"..
selected_config,
current_config)
print(
"Please restart camera")
shut_down()
end
elseif new_name then
write_ini(new_name, ccounend
This script is far from trivial, but it is developed with safety in mind. If
something goes wrong, you can still retrieve a working configuration from
the
.BAK
files.
Scripts like this are almost impossible to develop without a good debug
environment on a PC. We will discuss this topic in the next section.
Содержание 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 ...