I build a dictionary in tcl 8.4 inside a procedure. How do I use the constructed dictionary in another procedure. I have added a sample code of how I construct a dictionary in tcl 8.4. I know tcl 8.5 has in built in 'dict' option, but I have to use tcl 8.4.
proc a {} {
set test(key1) "value1"
set test(key2) "value2"
lappend keylist "key1"
lappend keylist "key2"
foreach key $keylist {
puts "value of $key is $test($key)"
}
}
So the procedure mentioned above builds a dictionary. But since tcl 8.4 interpreter interprets every line "$test($key)" as a separate variable how can I make it global so that I can use it in another procedure.