Canon Camera Hackers Manual page 107

Camera hackers manual berthold daum
Table of Contents

Advertisement

98
C H A P T E R 5
Scripting
i = 1
while i <= n do
sleep(10000)
shoot()
i = i + 1
end
does exactly the same as the first for loop shown at the beginning of this
section.
The construct repeat ... until behaves quite similarly:
i = 1
repeat
sleep 10000
shoot
i = i + 1
until i > n
The difference in the while construct, however, is that the loop body is
executed at least once because the condition is checked at the end of the
loop. The while construct may decide not to execute the loop body at all if
the condition after the while fails during the first pass.
Both while and repeat loops can be aborted with the break statement,
which always exits the innermost loop:
i = 1
while true do
if i > n then break end
sleep(10000)
shoot()
i = i + 1
end
Here we have used the Boolean value true in the while condition, which
results in a loop that never stops. To break the loop, we check the inverse
condition in the if statement and execute the break command if the con-
dition holds.
The above control statements are fully sufficient to express any kind of
control flow in a script— goto statements and labels are not really neces-
sary. Consequently, Lua does not offer GOTO.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents