GEOS SDK TechDocs
|
|
4.2 Expressions
|
4.4 Command Results
The third major way that strings are interpreted in Tcl is a list . A list is just a string with a list-like structure consisting of fields separated by white space. For example, the string:
Al Sue Anne John
is a list with four elements or fields. Lists have the same basic structure as command strings, except that a newline character in a list is treated as a field separator just like a space or tab. Conventions for braces and backslashes are the same for lists as for commands. For example, the string:
a b\ c {d e {f g h}}
is a list with three elements:
a
,
b c
, and
d e {f g h}
. Note the space between the
b
and
c
. Whenever an element is extracted from a list, the same rules about backslashes and braces are applied as for commands. Thus in the above example when the third element is extracted from the list, the result is:
d e {f g h}
(when the field was extracted, all that happened was to strip off the outermost layer of braces). Command substitution is never made on a list (at least, not by the list-processing commands; the list can always be passed to the Tcl interpreter for evaluation).
The Tcl commands
concat
,
foreach
,
index
,
length
,
list
, and
range
allow you to build lists, extract elements from them, search them, and perform other list-related functions.
GEOS SDK TechDocs
|
|
4.2 Expressions
|
4.4 Command Results