![background image](http://html.mh-extra.com/html/canon/camera/camera_hackers-manual_59969100.webp)
5.3 uBasic primer
91
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:
f
The first section
informs the user
which script functions are triggered by
pressing buttons.
f
The second section makes sure that
no bad parameter values
are passed
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.
f
The third section
initializes the variables
used in the processing section.
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.
f
The fourth section saves the
initial camera state
values into variables so
that the camera state can be restored at the end of the script.
f
Then, the
main processing
section performs the task that was intended
by the script.
f
Finally, at the end of the script, the initial
camera state is restored
. If the
script does not run to the end by itself (because it runs in a loop), you
Содержание 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 ...