Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

setting "current" namespace


Is there a way to set current name space in the interpreter such that
all further sourcing and  variable resolution be done relative to
"current" namespace?  There is a "namespace current" that reports
current namespace , but I could not find anything that would allow
namespace setting
On 11 Mai, 04:26, rod <orodio@gmail.com> wrote:

> Is there a way to set current name space in the interpreter such that
> all further sourcing and  variable resolution be done relative to
> "current" namespace?  There is a "namespace current" that reports
> current namespace , but I could not find anything that would allow
> namespace setting

You can assure that some code runs in namespace ::foo with
   namespace eval ::foo $code
As a big wrapper on topmost level, if you really want...
On May 11, 1:40 am, suchenwi <richard.suchenwirth-

bauersa@siemens.com> wrote:
> On 11 Mai, 04:26, rod <orodio@gmail.com> wrote:

> > Is there a way to set current name space in the interpreter such that
> > all further sourcing and  variable resolution be done relative to
> > "current" namespace?  There is a "namespace current" that reports
> > current namespace , but I could not find anything that would allow
> > namespace setting

> You can assure that some code runs in namespace ::foo with
>    namespace eval ::foo $code
> As a big wrapper on topmost level, if you really want...

I wanted to do this at a "higher" level, so that all the namespace
unaware scripts that follow automatically sourced and resolved in the
designated namespace
By doing some more searching I was able to find the answer  that
allows me to do exactly what I need.  Here is the link:

http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/16a...

Here is the piece of code to accomplish it:

proc SetNamespace {{Namespace {}}} {
      set prompt "% "
      if {[namespace tail $Namespace] != ""} {
            set prompt "([namespace tail $Namespace]) % "}
      while {1} {
            puts -nonewline $prompt
            flush stdout
            set cmd [gets stdin]
            while {![info complete $cmd]} {
                  set cmd "$cmd\n[gets stdin]"}
            catch {namespace eval $Namespace $cmd} result
            if {$result != ""} {
                  puts $result}}}

On May 10, 10:26 pm, rod <orodio@gmail.com> wrote:

> Is there a way to set current name space in the interpreter such that
> all further sourcing and  variable resolution be done relative to
> "current" namespace?

You can do this in an interactive tkcon session. There's a menu
item Console->Attach To->Namespace.... The same command
can be invoked on the command line using:
  tkcon master ::tkcon::AttachNamespace $namespace

Keith

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc