Script Development - Canon Camera Hackers Manual

Camera hackers manual berthold daum
Table of Contents

Advertisement

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 Notepad++ (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
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:
CHDK commands are not known in a PC environment and will raise
f
errors.
CHDK script parameters defined in the script header are not set be-
f
cause they are defined within a Lua comment block. All parameters will
have the value nil.
In a PC environment, Lua arithmetic is performed with floating point
f
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!
http://lua-users.org/wiki/LuaIntegratedDevelopmentEnviron-

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents