Loops - Canon Camera Hackers Manual

Camera hackers manual berthold daum
Table of Contents

Advertisement

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:

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents