Comments; Script Structure - Canon Camera Hackers Manual

Camera hackers manual berthold daum
Table of Contents

Advertisement

5.3.9 Comments

Anything behind a rem command (including the rem command) is regarded
as a comment and has no influence on processing.
gosub "waitdisp" rem waits on disp
Almost no influence, that is.
rem waits on disp
gosub "waitdisp"
will execute slower because the extra line attracts a delay of 10 millisec-
onds. So don't overdo it with comments in scripts. Comments need space,
too, and space can become scarce for complex scripts. The CHDK sets an
upper limit of 8 KB on each uBasic script.

5.3.10 Script structure

A script starts with a header section that defines the title and the parame-
ters, as we saw in section 5.2. This is followed by the main body of the
script. Subroutines are usually defined at the end of the script.
The main body typically consists of seven parts:
The first section informs the user which script functions are triggered by
f
pressing buttons.
The second section makes sure that no bad parameter values are passed
f
to the processing section. Usually, when a bad parameter value is de-
tected, the default parameter value is assigned. In addition, you may
want to print a message onto the display.
The third section initializes the variables used in the processing section.
f
Initial variable values may be fixed or may depend on parameter values.
It may also be necessary to scale parameter values. For example, a pa-
rameter accepts values in centimeters but is fed into a uBasic command
that expects millimeters. In this case, we would multiply the parameter
value by 10.
The fourth section saves the initial camera state values into variables so
f
that the camera state can be restored at the end of the script.
Then, the main processing section performs the task that was intended
f
by the script.
Finally, at the end of the script, the initial camera state is restored. If the
f
script does not run to the end by itself (because it runs in a loop), you
5.3 uBasic primer
91

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents