johnlopez2000
Programmer
I am creating a nested namespace to create structures for varied computer information. The base namespace is xComputer, then inside it is ::xComputer::${x} where x=the COMPUTERNAME. Please see code below:
so far so good. but now I attempt to 'discover' the namespace children and extract the content of HomeLAN:
some variations on the above:
I am sure this can be done, but I am apparently missing the obvious.
Thanks for your help.
John Lopez
Enterprise PDM Architect
Code:
% namespace eval xComputer { }
% set x LOCALHOST
LOCALHOST
% namespace eval ::xComputer::$x { }
% set ::xComputer::${x}::HomeLAN "170.121.142"
170.121.142
% set x yyz0db03
yyz0db03
% namespace eval ::xComputer::$x { }
% set ::xComputer::${x}::HomeLAN "170.121.143"
170.121.143
% namespace children ::xComputer
::xComputer::yyz0db03 ::xComputer::LOCALHOST
so far so good. but now I attempt to 'discover' the namespace children and extract the content of HomeLAN:
Code:
% foreach x [namespace children ::xComputer] { puts $::xComputer::$x::HomeLAN }
can't read "::xComputer::": no such variable
some variations on the above:
Code:
% puts $::xComputer::${x}::HomeLAN
can't read "::xComputer::": no such variable
% puts ${::xComputer::${x}::HomeLAN}
can't read "::xComputer::${x": no such variable
% puts $(::xComputer::${x}::HomeLAN)
can't read "(::xComputer::::xComputer::yyz0db03::HomeLAN)": no such variable
% puts ${::xComputer::$(x)::HomeLAN}
can't read "::xComputer::$(x)::HomeLAN": no such variable
%
I am sure this can be done, but I am apparently missing the obvious.
Thanks for your help.
John Lopez
Enterprise PDM Architect