96
C H A P T E R 5
Scripting
it is possible to write:
if a < 0 then
b = -1
elseif a > 0 then
b = 1
else
b = 0
end
which is easier to read and to understand.
Lua
does not feature a
select
statement (section 5.3.5), but a sequence of
elseif
clauses can be used for
the same purpose.
Relational operators allowed in
Lua
are:
==
(equals) (
uBasic:
=
)
>
(greater than)
<
(less than)
~=
(not equal) (
uBasic:
<>
)
<=
(less than or equal)
>=
(greater than or equal)
It is also possible to connect several conditions with the operators
and
,
or
,
and
not
. Parentheses may be used to indicate which operators are executed
first:
if (a = 1 or a = 2) and b < 0 then ...
5.4.8
Loops
Similar to
uBasic,
the
for
-loop is used for incrementing a counter from a
start value to an end value and for executing the instructions within the
loop for each counter value. For example:
for i = 1,n do
sleep(10000)
shoot()
end
takes
n
shots every 10 seconds.
By default, the increment value of the
for
construct is 1. By using a third
value in the
for
clause, however, it is possible to specify a different incre-
ment value:
Содержание 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 ...