Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with the variables scope.

Status
Not open for further replies.

ahmaka

Programmer
Nov 29, 2009
1
DE
Hi!
I am new to Tcl/Tk and I need some help :).

My procedure is:
Code:
proc changeText {data} {
   upvar #0 $data v
   set w .f.f0.u
   set vehicleNum $v(Tag)
	
   # changing the text 
   $w bind $v(Tag) <Button-1>  { 	
            upvar 1 $vehicleNum v 
	    set num $v
            set QuTxt(NumberOfCarsBehind) $num
            }
}

The idea is to take the number of the rectangle when you click on one. But I get an error:
ERROR: can't read "vehicleNum": no such variable

command bound to event:
"upvar 1 $vehicleNum v "



Any ideas ?
Thank you in advance.
 
upvar is, in my opinion, complicated. I think your problem is that you referred to the value of vehicleNum ($vehicleNum), rather than its name (which is vehicleNum) which is what the upvar syntax requires.

I used to try to use scope changes but I've gotten to where I just refer to the variable in the global scope ($::vehicleNum).

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top