Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

iwidgets 2.0.1 and DP

4 views
Skip to first unread message

J.M. VandeVegt

unread,
Apr 2, 1996, 3:00:00 AM4/2/96
to
How can I detect the presence of 'configbody' commands in
defined classes?

I'm revamping the auto_load_all procedure to work with itcl. With help
from some netfriends, I've isolated the namespace name from the commands,
but commands defined with 'configbody' don't seem to show up
with 'info commands'. Here's what I have so far, any help
appreciated.
# rpc.tcl --
#
....[other commands deleted]
########################################################################
#
# auto_load_all
#
# This procedure source's all Tcl library scripts not already source'd.
# This procedure is useful for when you want to later undefine
# the "proc" command, for making your interpreter RPC safe.
#

proc auto_load_all {} {
global auto_index;

set catchout {}
set noitcl 1
#
# The next info command will either trigger an error or return
# a null string if itcl has not been initialized. Either way,
# catchout retains the null string when itcl is not present.
#
catch {info namespace all itcl} catchout

#
# If the info command returned the string 'itcl' then
# itcl is present.
#
if {[string compare $catchout "itcl"] == 0} {
set noitcl 0
}

if {$noitcl} {
foreach name [array names auto_index] {
if {[string length [info commands $name]] == 0} {
uplevel #0 $auto_index($name);
}
}
} else {
#
# Checking for loaded commands is a little messier when itcl is
# loaded since commands in namespaces don't show up when 'info'
# is executed outside of the particular namespace.
#
foreach name [array names auto_index] {
#
# First, let's get the fully qualified namespace name
# and the command name separated.
#
set namespace [info namespace qualifiers $name]
set cmd [info namespace tail $name]
#puts stderr "searching for namespace $namespace, command $cmd"
#
# If the namespace is null, we are in the global space and we should
# process this command like itcl wasn't here.
#
if {[string length $namespace] == 0} {
if {[string length [info commands $name]] == 0} {
uplevel #0 $auto_index($name);
continue;
}
}
#
# OK, our command name includes a namespace, but let's make sure
# the namespace exists before be implicitly create it with the
# namespace command. We'll assume that if the namespace referenced
# in the command does not exist, the file that we would source
# would define it. This seems to be a safe assumption, for now.
#
if {[string length [info namespace all $namespace]] == 0} {
uplevel #0 $auto_index($name)
continue
}
#
# If everything else checks out, issue the 'info commands' command
# inside the respective namespace to determine the presence
# of the command.
#
if {[string length [namespace $namespace "info commands $cmd"]] == 0} {
#puts stderr "could not find $name"
#puts stderr "loading $auto_index($name)"
uplevel #0 $auto_index($name)
}
}
}
}
--
|----Jim VandeVegt----| Computer Systems Engineer |===UNIX--WWW--FTP--EMAIL===|
|-Lucent Technologies-| j...@ohgua.att.com | |
|-----Omaha Works-----| vand...@csealumni.unl.edu| Nothing But Net |
|--formerly AT&T NSG--|--#include <disclaimer.h>--|===========================|

0 new messages