Issues.00364 - lordmundi/wikidoctest GitHub Wiki
00364: add pdict routine for pretty printing of tcl dictionaries
Summary: add pdict routine for pretty printing of tcl dictionaries
Created: 2011–06–02 17:58
Status: Released
Category: Request
From: frankie
Version: 2.2
Released_In: 2.3
Description:
tcl dictionaries are becoming more common now that EDGE is using tcl 8.5. A command to easily print them would be useful. The procedure here would be nice to have in the edge distribution:
Comments
frankie October 19, 2012, at 01:53 PM: This was added in as part of the commits for Issue 00393. The routine name is "pdict". The usage is as follows:
# -- pdict
#
# Pretty print a dict similar to parray.
#
# USAGE:
#
# pdict d [i [p [s]]]
#
# WHERE:
# d - dict value or reference to be printed
# i - indent level
# p - prefix string for one level of indent
# s - separator string between key and value
#
# EXAMPLE:
# % set d [dict create a {1 i 2 j 3 k} b {x y z} c {i m j {q w e r} k o}]
# a {1 i 2 j 3 k} b {x y z} c {i m j {q w e r} k o}
# % pdict $d
# a ->
# 1 -> 'i'
# 2 -> 'j'
# 3 -> 'k'
# b -> 'x y z'
# c ->
# i -> 'm'
# j ->
# q -> 'w'
# e -> 'r'
# k -> 'o'
# % pdict d
# dict d
# a ->
# ...