cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
s002hwj
Observer
Observer
330 Views
Registered: ‎07-14-2020

passing variable/parameter

is there way to passing variable parameter between linked .tcl  for example

in my top.tcl

set a 5

 source sub.tcl

put $a

in sub.tcl

  set a 7

 

result output will be 7 in the top.tcl

0 Kudos
1 Reply
avrumw
Guide
Guide
282 Views
Registered: ‎01-23-2009

This is the normal behavior of Tcl.

A "source" command simply executes the Tcl commands located in the file. These commands are executed in the same context (same namespace) as where it was called from. In other words, the commands in a file that is "sourced" are not a subprogram.

This is not like calling a procedure. A procedure is defined with a "proc" command and executed by invoking the named procedure (with arguments). The procedure is executed in a different namespace; any variable used in a procedure is in a different namespace than the calling scope.

Avrum