![background image](http://html.mh-extra.com/html/canon/camera/camera_hackers-manual_59969107.webp)
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.
Содержание 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 ...