Cancel
Showing results for 
Search instead for 
Did you mean: 

TCL : Shop docs

Legend
Legend

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
Production: NX11.0.2.7,VERICUT 7.3.3
Development: Tcl/Tk, Gnuplot
www.deshors-tiremold.com
4 REPLIES

Re: TCL : Shop docs

Phenom
Phenom

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

Legend
Legend

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
Production: NX11.0.2.7,VERICUT 7.3.3
Development: Tcl/Tk, Gnuplot
www.deshors-tiremold.com

Re: TCL : Shop docs

Esteemed Contributor
Esteemed Contributor
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


Re: TCL : Shop docs

Phenom
Phenom

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