94
C H A P T E R 5
Scripting
Such dictionary tables should not be accessed via indices because no as-
sumptions can be made about the order in which the elements are stored.
Note that keys must not contain white space.
5.4.4
Assignments
Assignments look very similar to those in
uBasic,
except that the
let
com-
mand is not used:
a = b * c
Lua
supports the same arithmetic operators as
uBasic,
plus the
^
operator
for exponentiation.
Assigning values to table elements is possible, too. For example:
t[i] = [[multi-line
string]]
Another difference is that lists of values can be assigned to lists of vari-
ables. For example:
a, b = 3, 4
assigns 3 to
a
and 4 to
b
. This form of assignment is often used for func-
tions that return multiple values. If individual values are not needed, the
anonymous variable “_” can be used:
_, b = 3, 4
Here, 4 is assigned to
b
and 3 is thrown away.
5.4.5 Output
The
print()
function can be used to create output on the display. Similar
to
uBasic,
several parameters can be specified, but the semantics are differ-
ent: individual values are separated by
TAB
, not by a single white space. The
semicolon cannot be used to concatenate two strings. Instead, we use the
string concatenation operator (
..
). For example:
print('a:
'
..a..
'
s
'
)
would produce the output
a: 500s
if the variable
a
had the value of 500. Unlike
uBasic, Lua
allows the output
of strings longer than 25 characters. Longer strings are wrapped into the
next line.
Summary of Contents for Camera
Page 1: ......
Page 2: ...The Canon Camera Hackers Manual ...
Page 3: ......
Page 4: ...Berthold Daum The Canon Camera Hackers Manual Teach Your Camera New Tricks ...
Page 19: ...10 CH APTER 2 Cameras and Operating Systems ...
Page 25: ...16 CH APTER 3 ...
Page 85: ...76 CH APTER 4 Teach Your Camera New Tricks ...
Page 213: ...204 CH APTER 6 ...
Page 253: ...244 AP PENDIX ...