annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/tcl8.6/parray.tcl @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 # parray:
jpayne@68 2 # Print the contents of a global array on stdout.
jpayne@68 3 #
jpayne@68 4 # Copyright (c) 1991-1993 The Regents of the University of California.
jpayne@68 5 # Copyright (c) 1994 Sun Microsystems, Inc.
jpayne@68 6 #
jpayne@68 7 # See the file "license.terms" for information on usage and redistribution
jpayne@68 8 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@68 9 #
jpayne@68 10
jpayne@68 11 proc parray {a {pattern *}} {
jpayne@68 12 upvar 1 $a array
jpayne@68 13 if {![array exists array]} {
jpayne@68 14 return -code error "\"$a\" isn't an array"
jpayne@68 15 }
jpayne@68 16 set maxl 0
jpayne@68 17 set names [lsort [array names array $pattern]]
jpayne@68 18 foreach name $names {
jpayne@68 19 if {[string length $name] > $maxl} {
jpayne@68 20 set maxl [string length $name]
jpayne@68 21 }
jpayne@68 22 }
jpayne@68 23 set maxl [expr {$maxl + [string length $a] + 2}]
jpayne@68 24 foreach name $names {
jpayne@68 25 set nameString [format %s(%s) $a $name]
jpayne@68 26 puts stdout [format "%-*s = %s" $maxl $nameString $array($name)]
jpayne@68 27 }
jpayne@68 28 }