If you're writing a Tcl proc, you'll normally pass in parameters by value, specifying a $ in front of the variable whos contents you want to pass in in the calling sequence:
dojob $passin
If, however, passin is a Tcl array, tis won't work since $passin cannot be expanded to string. So you'll need to make the call using:
dojob passin
and then use upvar within the proc to access the data.
INDIVIDUAL ELEMENTS of an array CAN be passed in to a Tcl Proc by value as they're simple strings:
dojob $passin(demo)
or
dojob $passin($elname)
References: our
Procedures and Variable Scope and
Tcl Array modules
(written 2004-11-18, updated 2006-06-05)
Associated topics are indexed under
T207 - Tcl/Tk - Procedures and Variable Scope [3414] Passing back multiple results in Tcl - upvar and uplevel - (2011-09-01)
[3192] Tcl - Some example of HOW TO in handling data files and formats - (2011-03-04)
[2929] Passing a variable number of parameters in to a function / method - (2010-08-20)
[2520] Global and Enable - two misused words! - (2009-11-30)
[2476] Tcl - uplevel to run code at calling level - (2009-10-24)
[2466] Tcl - passing arrays and strings in and back out of procs - (2009-10-22)
[1782] Calling procs in Tcl and how it compares to Perl - (2008-09-02)
[1404] Tcl - global, upvar and uplevel. - (2007-10-24)
[1163] A better alternative to cutting and pasting code - (2007-04-26)
[775] Do not duplicate your code - (2006-06-23)
[409] Functions and commands with dangerous names - (2005-08-11)
[308] Call by name v call by value - (2005-05-11)
[96] Variable Scope - (2004-10-22)
T208 - Tcl/Tk - Arrays and dicts [3582] Tcl collections - lists, dicts and array - (2012-01-16)
[3415] User defined sorting and other uses of callbacks in Tcl and Tk - (2011-09-02)
[1614] When an array is not an array - (2008-04-17)
[1427] Arrays in Tcl - a demonstration - (2007-11-10)
[1405] Sorting in Tcl - lists and arrays - (2007-10-24)
[1283] Generating traffic for network testing - (2007-07-29)
[1282] Stringing together Tcl scripts - (2007-07-29)
[779] The fragility of pancakes - and better structures - (2006-06-26)
Some other Articles
Feedback shows the tip of an icebergStaff theftPHP v JavaShort underground journeys and a PHP bookPassing arrays to procs in TclFair and SimpleGood early morningPHP course. Come by train.History around youA case of case