Inside a Tcl proc, I need to refer to variables both in the context of this proc as well as the level above because the file that is getting sourced uses variables there. So I tried writing something like:
proc source_file {file} {
uplevel {source $file }
}
The problem with that is inside the 'uplevel' command, I can refer to variables at the top level, but now the local $file variable is not defined. I was hoping I can fix that by exposing the proc variable as file_up in the uplevel context, but that's not working either:
proc source_file {file} {
upvar "file_up" $file
uplevel {source $file_up }
}
source_file test.tcl
can't read "file_up": no such variable
What am I doing wrong?