Jump to content
Sign in to follow this  
varthamanan

how to get the variable values from two different script

Recommended Posts

I have script something like this


 


##########################################################


first script.tcl


 


proc firstscript {} {


variable i


 


set i 10


}


#=======================================================


secondscript.tcl


 


proc secondscript {} {


variable i


puts $i


}


 i struggling lot because of this problem.


 


I ran the first script, in the script I set the variable  set i 10


 


i want get variable value $i in the second script


 


i tried with global , variable  options


 


Please give some suggestion or solution


 


Thanks in advance


 


Thanks and Regards


P.Varthamanan


Share this post


Link to post
Share on other sites

I have script something like this

 

##########################################################

first script.tcl

 

proc firstscript {} {

variable i

 

set i 10

}

#=======================================================

secondscript.tcl

 

proc secondscript {} {

variable i

puts $i

}

 i struggling lot because of this problem.

 

I ran the first script, in the script I set the variable  set i 10

 

i want get variable value $i in the second script

 

i tried with global , variable  options

 

Please give some suggestion or solution

 

Thanks in advance

 

Thanks and Regards

P.Varthamanan

 

 

it's due to variable i was not declared in any namespace by "variable" keyword before

to access global variables, use variable with full name, for example "set ::i 10",  "puts $::i"

varthamanan likes this

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...