194
C H A P T E R 5
Scripting
5.8
Script
development
Simple scripts can be developed with a plain text editor such as
Notepad
and can be tested directly in-camera. For larger scripts, however, this can
become tedious: edit the script on the PC, move the memory card to the
camera, reboot the camera, run the script and find the next syntax error,
move the card back to the PC, correct the error, and so on.
For larger scripts, it is much more convenient to gather some tools that
allow editing within a PC environment. About 80 percent of all bugs can be
caught easily while testing on the PC. After completing these tests, you will
still need to do some testing in-camera—but the cycle will be much shorter.
For
uBasic,
there is a small integrated development environment (IDE)
targeted at CHDK development. The program
UBDB
from
Dave Mitchell
(
www.zenoshrdlu.com/kapstuff/zubdb.html
) features a simple editor and
a debugger. The debugger allows you to set breakpoints and step through
a script line by line. Between the steps, you have the ability to change the
values of parameters, variables, CHDK commands ( functions), and CHDK
properties, allowing you to test the script under various conditions.
UBDB
is written in Java and runs on both Windows and Mac OSX platforms.
Another comfortable editor on Windows platforms is the Open Source
product
+
(
http://notepad-plus.sourceforge.net/uk/site.htm
).
This editor is free and knows the syntax of many languages, including
uBasic
and
Lua
.
For
Lua,
several IDEs exist for different platforms. You can find a list of
IDEs under
http://lua-users.org/wiki/LuaIntegratedDevelopmentEnviron-
ments
.
One of them is the
SciTE IDE
that comes with the
Lua for Windows
dis-
tribution (
http://luaforwindows.luaforge.net
).
SciTE
integrates a debugger
that allows setting breakpoints and stepping through the script line by
line. However, several difficulties arise when testing CHDK
Lua
scripts un-
der such an IDE:
f
CHDK commands are not known in a PC environment and will raise
errors.
f
CHDK script parameters defined in the script header are not set be-
cause they are defined within a
Lua
comment block. All parameters will
have the value
nil
.
f
In a PC environment,
Lua
arithmetic is performed with floating point
numbers. Under the CHDK, in contrast, arithmetic is performed with
integers. In particular, the division operator (
/
)works differently in these
environments: while 3/4 is
0.75
on a PC, it is
0
under the CHDK!
Содержание 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 ...