Usage:
Used when we have to change the value of a global variable
from inside a procedure’s scope
Example
proc example {one two} {
upvar $one local1
upvar $two local2
set local1 Kavitha
set local2 Anbarasu
}
set glob1 David
set glob2 Beckam
puts $glob1
puts $glob2\n
example glob1 glob2
puts $glob1
puts $glob2
Output
DavidBeckam
Kavitha
Anbarasu
In the above example we are able to change the value of two global variables glob1 and glob2 from within a procedure
Nice.. I understood clearly now. Thanks
ReplyDeleteGood example..
ReplyDeletelucidly described
ReplyDeletevery nice thanQ, got to know the usage of UPVAR ...
ReplyDeleteGood and simple example Kavitha. Thank you for making me understanding this concept.
ReplyDeleteI'm scratching my head actually.Thanks :)
ReplyDeleteThis was awesome example
ReplyDeletenice one
ReplyDeletethanks a lot!! Very clear
ReplyDeleteThanks a lot Kavitha.....very nice and simple explanation of upvar... :)
ReplyDeletecheers
Thanks Kavitha
ReplyDeleteThanks it really is quite clear.
ReplyDeleteThanks admin for sharing this information.
ReplyDeleteTCL Price in Pakistan
Holy sizz if this didnt make this so damn simple to understand. All this extra fluff and convolution in the other sources. You rock!
ReplyDelete