Assigning values
In this section we will be creating a nested dictionary containing multiple entries for each record. By using the Tcl dict with
command we will then assign variables in the body of our script that are based on the keys stored within our dictionary. The dict with
command allows us to accomplish this by assigning entries within our dictionary to variables and then executing a script. The syntax is as follows:
dict with name keys… script
How to do it…
In the following example, we will create a nested dictionary to hold a collection of key/value pairs and then using the dict for
and with
commands we will execute a script to output the values to the screen. Return values from the commands are provided for clarity. Enter the following command:
% set person1 [dict create firstname John lastname Smith title Manager] firstname John lastname Smith title Manager % set person2 [dict create firstname Mary lastname Jones title Developer] firstname Mary lastname Jones title Developer}...