]>
Commit | Line | Data |
---|---|---|
1 | # parray: | |
2 | # Print the contents of a global array on stdout. | |
3 | # | |
4 | # $Header: /sprite/src/lib/tcl/scripts/RCS/parray.tcl,v 1.1 91/09/26 09:55:03 ouster Exp $ SPRITE (Berkeley) | |
5 | # | |
6 | # Copyright 1991 Regents of the University of California | |
7 | # Permission to use, copy, modify, and distribute this | |
8 | # software and its documentation for any purpose and without | |
9 | # fee is hereby granted, provided that this copyright | |
10 | # notice appears in all copies. The University of California | |
11 | # makes no representations about the suitability of this | |
12 | # software for any purpose. It is provided "as is" without | |
13 | # express or implied warranty. | |
14 | # | |
15 | ||
16 | proc parray a { | |
17 | global $a | |
18 | set maxl 0 | |
19 | foreach name [lsort [array names $a]] { | |
20 | if {[string length $name] > $maxl} { | |
21 | set maxl [string length $name] | |
22 | } | |
23 | } | |
24 | set maxl [expr {$maxl + [string length $a] + 2}] | |
25 | foreach name [lsort [array names $a]] { | |
26 | set nameString [format %s(%s) $a $name] | |
27 | puts stdout [format "%-*s = %s" $maxl $nameString [set ${a}($name)]] | |
28 | } | |
29 | } |