how to get the variable values from two different script

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

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

Tagged:

Answers

  • tinh
    tinh Altair Community Member
    edited August 2015

    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'