5.3 uBasic primer
87
Relational operators allowed in
uBasic
are:
=
(equals)
>
(greater
than)
<
(less
than)
<>
(not equal)
<=
(less than or equal)
>=
(greater than or equal)
It is possible, too, to connect several conditions using the operators
and
,
or
,
xor
, and
not
. Parentheses may be used to indicate which operators are ex-
ecuted first:
if (a = 1 or a = 2) and b < 0 then ...
If there is nothing to do in the
else
case, the
else
clause can be omitted:
b = 4
if a < 0 then
b = 3
endif
does just the same and runs faster because each program line in
uBasic
involves a delay of 10 msec.
In simple cases, it is possible to combine all of these statements into
one line and omit the
endif
:
if a < 0 then b = 3 else b = 4
or
b = 4
if a < 0 then b = 3
Here, the second version is slower because it needs two lines of code.
Note:
This shorthand notation without an
endif
can, however, only be
used standalone and not nested inside another
if ... then ... else ...
endif
construct. In this latter case, you must use the full statement prop-
erly closed with
endif
.
5.3.5
Case
structures
The
select
statement is a convenient way to avoid complex
if ... then
... else
constructs. It allows executing different statements depending
on the value of a variable:
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 ...