On Tue, 15 Jun 1999 [EMAIL PROTECTED] wrote:

> I'm unable to access then NT System Environment from a proc that has been
> previously sourced in. Example included.
> 
> I am adding java functionality to an existing test harness. It consists
> of a group of files containing procs all of which are sourced in when the
> test harness is kicked off. I've noticed that the System's Environment
> Variables, such as PATH and CLASSPATH are not accessible from within any
> proc that has been previously sourced in.
> 
> I am able to reproduce this problem in the following simple example:
> 
> Create a file named foo.tcl with the following 3 lines
> 
> proc Foo {} {
>     puts "CLASSPATH = $env(CLASSPATH)"
> }
> 
> While in the directory that contains foo.tcl, start tclsh and issue the
> following three commands.
> 
> Here's what it does for me:
> 
> c:\> tclsh
> % echo $env(CLASSPATH)
> ".;c:\tcl8.0\lib\tclblend1.1.1\tcljava.jar;c:\tcl8.0\lib\tclblend1.1.1\
> tclblend.jar;c:\jdk1.1.7B\bin;c:\jdk1.1.7b\lib\classes.zip
> % source foo.tcl
> % Foo
> can't read "env(CLASSPATH)": no such variable
> % exit

You need to bring the variable into the proc using the global command.
This is basic Tcl stuff that any Tcl book or website could explain in
more detail.

like so.
proc Foo {} {
  global env
  puts "CLASSPATH = $env(CLASSPATH)"
}

later
mo

 
> 
> I'd appreciate any help if someone can show me how to access the System's
> Environment Variables, such as CLASSPATH and PATH from inside a proc that
> has been initially sourced in, then later called.
> 
> thanks for your help,
> Mike Bryan
> [EMAIL PROTECTED]
> 
> ----------------------------------------------------------------
> The TclJava mailing list is sponsored by WebNet Technologies.
> To subscribe:    send mail to [EMAIL PROTECTED]  
>                  with the word SUBSCRIBE as the subject.
> To unsubscribe:  send mail to [EMAIL PROTECTED] 
>                  with the word UNSUBSCRIBE as the subject.
> To send to the list, send email to '[EMAIL PROTECTED]'. 
> A list archive is at: http://www.findmail.com/listsaver/tcldallas/
> 

----------------------------------------------------------------
The TclJava mailing list is sponsored by WebNet Technologies.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
A list archive is at: http://www.findmail.com/listsaver/tcldallas/

Reply via email to