Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

TCL : Shop docs

hi,

 

I have this problem all the time, when I declare a variable in a proc, I can never get it out in another proc.

 in my example I want the "nb_caractere" in my proc information, but the result is always "0"
can you help me?

 

ex :

 

 

set nb_caractere 0

#==============================================================================
proc MOM_OPER_BODY { } {
#==============================================================================
  global mom_oper_geom
  global mom_oper_program

set origine_et_prog "$mom_oper_program$mom_oper_geom"
set nb_caractere [string length "$origine_et_prog"]

   }  
#==============================================================================
proc information { } {
#==============================================================================

 global nb_caractere


 MOM_output_literal "<u ALIGN=LEFT WIDTH=50%><FONT COLOR=999999>$nb_caractere </FONT></u>"

}
@mkn
4 REPLIES

Re: TCL : Shop docs

[ Edited ]

Inside each proc is a change in scope. The global declaration has to be made in them (for that variable) or it will be a local variable inside them. So - MOM_oper_body needs a global declartion for that variable (where you set it.)

NX10.03
Windows 7 Pro

Re: TCL : Shop docs

i 'm not in the office , but if i understand the global declaration must be outside and not inside of my proc .
I will try tomorrow

@mkn

Re: TCL : Shop docs

global nb_caractere 
set nb_caractere 0

#=================================================​=============================
proc MOM_OPER_BODY { } {
#=================================================​=============================
  global mom_oper_geom
  global mom_oper_program
global nb_caractere 
# if you need it elsewhere
global  origine_et_prog 

set origine_et_prog "$mom_oper_program$mom_oper_geom"
set nb_caractere [string length "$origine_et_prog"]

   }  
#=================================================​=============================
proc information { } {
#=================================================​=============================

 global nb_caractere


 MOM_output_literal "<u ALIGN=LEFT WIDTH=50%><FONT COLOR=999999>$nb_caractere </FONT></u>"

}
Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Solution
Solution
Accepted by topic author mkn
‎08-26-2015 04:32 AM

Re: TCL : Shop docs

It has to be both. Everywhere you set or reference it. You are setting it outside of the procs and inside ach of them - 3 global statements.

NX10.03
Windows 7 Pro

Learn online





Solution Information