]> www.wagner.pp.ru Git - oss/ck.git/blob - library/showglob.tcl
Ck console graphics toolkit
[oss/ck.git] / library / showglob.tcl
1 #
2 # showglob.tcl --
3 #
4 # This file defines a command for retrieving Tcl global variables.
5 #
6 # Copyright (c) 1996 Christian Werner
7 #
8 # See the file "license.terms" for information on usage and redistribution
9 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
11 proc showglob args {
12     set result {}
13     if {[llength $args] == 0} {
14         set args *
15     }
16     foreach i $args {
17         foreach k [info globals $i] {
18             set glob($k) {}
19         }
20     }
21     foreach i [lsort -ascii [array names glob]] {
22         upvar #0 $i var
23         if [array exists var] {
24             foreach k [lsort -ascii [array names var]] {
25                 lappend result set [list $i]($k) $var($k)
26                 append result "\n"
27             }
28         } else {
29             catch {lappend result set $i $var}
30             append result "\n"
31         }
32     }   
33     return $result
34 }
35
36