DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
(TCL) commands by type

Keyed lists

Keyed lists provide a structured data type built upon standard Tcl lists. This provides a functionality similar to structs in the C programming language.

A keyed list is a list in which each element contains a key and value pair. These element pairs are stored as lists themselves, where the key is the first element of the list, and the value is the second. The key-value pairs are referred to as fields. This is an example of a keyed list:

   {{NAME {Frank Zappa}} {JOB {musician and composer}}}
If the variable person contained the above list, then keylget person NAME would return {Frank Zappa}. Executing the command:

keylset person ID 106

would make person contain:

   {{ID 106} {NAME {Frank Zappa}} {JOB {musician and composer}}
Fields may contain subfields; ``.'' is the separator character. Subfields are actually fields where the value is another keyed list. Thus, the following list has the top level fields ID and NAME, and subfields NAME.FIRST and NAME.LAST:
   {ID 106} {NAME {{FIRST Frank} {LAST Zappa}}}
There is no limit to the recursive depth of subfields, allowing you to build complex data structures.

Keyed lists are constructed and accessed by a number of commands. All keyed list management commands take the name of the variable containing the keyed list as an argument (that is, passed by reference), rather than passing the list directly.

Available commands are:


keyldel(TCL)
deletes a key and value from a keyed list

keylget(TCL)
returns the value associated with a key from a keyed list

keylkeys(TCL)
returns the list of keys in the keyed list

keylset(TCL)
sets the value of a key in a keyed list

Next topic: String and character manipulation commands
Previous topic: Math commands

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003