On Wed, 28 Jun 2000, Frank Krahmer wrote:

> I have a question regarding access of global variables :
> 
> I have two tcl-scripts :
> 
> 1.) init.tcl :
> 
> package require java
> proc init {} {
>       # create global variable
>       set teststring [java::new String "abcabc"]
> }
> 
> 2.) access.tcl :
> 
> package require java
> proc access {} {
>       set resstring [$teststring concat "123"]
>       puts "Result : $resstring"
> }
> 
> After loading both scripts in java.lang.Shell via source-command I execute
> first init, then access.
> I get the error "can't read "teststring": no such variable".
> 
> Isn't the variable $teststring created in the global namespace by execution
> of init.tcl ?
> How can I access $teststring fom access.tcl ?

You might want to take another pass at an into to Tcl book
or manual before you make all the beginner mistakes. Tcl
variables and not global by default. You can set a global
from inside a proc like this:

set ::resstring something

To can get the value like so:

puts $::resstring
 

> Another question :
> ==================
> I am able to load tcl-scripts into the java.lang.Shell by the source-command.
> Is it possible to unload and free the shell from the loaded script ?
> 
> Thanx
> Frank

I am not sure what you mean. Is this what you did?

( in the build dir )

$ make shell
% source file.tcl

( from the installed script )

$ jaclsh
% source file.tcl


What exactly went wrong? What error was printed?

Mo DeJong
Red Hat Inc

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
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]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to