Canon Camera Hackers Manual page 117

Camera hackers manual berthold daum
Table of Contents

Advertisement

108
C H A P T E R 5
Scripting
lists the contents of the specified directory. The result is returned as a table
of file names. If the function fails, nil is returned, followed by an error
message and an error number. If the optional parameter showall is true,
the list will contain the entries ".", "..", and deleted entries, too.
String manipulation functions
The CHDK implements the Lua string manipulation library completely. The
library comes with some powerful functions:
l = string.len(s)
Returns the character length of a string. The same is achieved with the operator #:
l = #s
t = string.rep(s,n)
Returns a string where string s is repeated n times.
t = string.upper(s)
Returns string s converted to upper case.
t = string.lower(s)
Returns string s converted to lower case.
t = string.sub(s, from, to)
Returns a substring of s starting at position from and ending at position to.
Indexes start at 1; negative indexes are counted from the end of the string.
t = string.char(n,...)
Converts the integer parameters to characters and concatenates them to a string.
n = string.char(s, i)
Converts the i-th character of s into an integer. Indexes start at 1; negative indexes
are counted from the end of the string.
t = string.format(f, n1,...)
Formats the content of the parameters n1,... with the help of format description f.
The formatting rules are quite similar to that of the printf() statement of ANSI C.
For example
tag, title = "b", "chdk"
string.format("<%s>%s</%s>", tag, title, tag)
returns
<b>chdk</b>
Often used format characters are the following:
%d %i
Decimal signed integer
%o
Octal integer
%x %X
Hex integer
%u
Unsigned integer
%c
Character

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Powershot sx10 is

Table of Contents