home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
dirs
/
tcl_447.lzh
/
TCL
/
tcl.lzh
/
tcl
/
help
/
lists
< prev
next >
Wrap
Text File
|
1990-05-03
|
1KB
|
35 lines
LISTS
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 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}.
Whenever an element is extracted from a list, the same rules
about backslashes and braces are applied as for commands.
Thus in the example above 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.