If you set a variable and want to use that variable in a Proc you have to use the "global" command on that variable. Then it becomes usable. Like:
=======
set foo "10"
proc bar {} {
global foo
puts "$foo"
}
=======
This would print 10
I understand this. However, what if I want to use a variable outside a proc that I started and modified in that proc? for instance:
========
set foo "10"
proc bar {} {
set var "5"
}
bar
puts $var
===========
how would I go about this? What i actually have is a procedure thats will run X times and when it runs I want to incr a value then call that value outside the proc.
Anyone care to clear this up for me?
=======
set foo "10"
proc bar {} {
global foo
puts "$foo"
}
=======
This would print 10
I understand this. However, what if I want to use a variable outside a proc that I started and modified in that proc? for instance:
========
set foo "10"
proc bar {} {
set var "5"
}
bar
puts $var
===========
how would I go about this? What i actually have is a procedure thats will run X times and when it runs I want to incr a value then call that value outside the proc.
Anyone care to clear this up for me?