TCL Training Series – Passing an array as procedure argument

A TCL array is an associative array. i.e. there is an (un-ordered) key-value pair in a TCL array. A simple list of elements as in a perl array or a C array is called a ‘list’ in TCL. If you want to pass an array, which s essentially a collection of variables, to a procedure in TCL, you can use the command upvar as explained earlier. You are passing a name to the procedure and then using it to access the array at the previous level.

You should see the results:
0.1, 0.2
Cap Tran

While we are at it, let’s see the difference with passing a list. Here we pass a variable to the procedure.

Leave a Reply

Your email address will not be published. Required fields are marked *