Assignments; Output - Canon Camera Hackers Manual

Camera hackers manual berthold daum
Table of Contents

Advertisement

94
C H A P T E R 5
Scripting
Such dictionary tables should not be accessed via indices because no as-
sumptions can be made about the order in which the elements are stored.
Note that keys must not contain white space.

5.4.4 Assignments

Assignments look very similar to those in uBasic, except that the let com-
mand is not used:
a = b * c
Lua supports the same arithmetic operators as uBasic, plus the ^ operator
for exponentiation.
Assigning values to table elements is possible, too. For example:
t[i] = [[multi-line
Another difference is that lists of values can be assigned to lists of vari-
ables. For example:
a, b = 3, 4
assigns 3 to a and 4 to b. This form of assignment is often used for func-
tions that return multiple values. If individual values are not needed, the
anonymous variable "_" can be used:
_, b = 3, 4
Here, 4 is assigned to b and 3 is thrown away.

5.4.5 Output

The print() function can be used to create output on the display. Similar
to uBasic, several parameters can be specified, but the semantics are differ-
ent: individual values are separated by TAB, not by a single white space. The
semicolon cannot be used to concatenate two strings. Instead, we use the
string concatenation operator (..). For example:
print('a: '..a..'s')
would produce the output
a: 500s
if the variable a had the value of 500. Unlike uBasic, Lua allows the output
of strings longer than 25 characters. Longer strings are wrapped into the
next line.
string]]

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents